When you pipe the result of a command to Get-Member, it examines the returned objects and shows the properties and methods. Use this line if you...
Powershell
Built-in Methods
Strings contain all the methods you may need to access its content or manipulate it otherwise. Here is how you can list those methods: "Hello" |...
Stopping Programs Gracefully
While Stop-Process will stop a process immediately in PowerShell, it will also destroy all data that hasn't yet been saved. You can try a more...
Create HTML System Reports
ConvertTo-HTML is a great way of creating system reports because you can combine information gathered from different sources into one report. The...
Create HTML reports
ConvertTo-HTML will convert text information into simple HTML, which can then be saved to disk. These reports will work fine, even though they are...
Printing Results
You will discover that Out-Printer can print results to your default printer. You can also print to any other printer when you specify its name:...
Outputting Text Data to File
When you output results to text files, you will find that the same width restrictions apply that are active when you output into the console. You...
Examining Object Data
If you need to see all properties a result object provides, you should probably add Select-Object * to it like this: Get-Process -Id $pid |...
Multi-Column Lists
If you need to display a lot of information in as little room as possible, you should use Format-List with -Column: Get-Service | Format-Wide...
Create Groups (and Examine Alias groups)
Format-Table has a parameter called -GroupBy which creates groups based on the property you supply. For example, you can use this to examine aliases...
Getting IPv4 Addresses
You should use WMI to list all IPv4 addresses assigned to a computer: Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled...
Automating Native Commands
You'll discover that some native commands require interactive keystrokes before they work. For example, to format a drive, for security reasons you...
Finding Update History
Whenever Windows installs an update via Windows Update, it will log this in its windowsupdate.log file. PowerShell can then parse this file. You...
Get Assigned IP Addresses
If you've ever wanted to know all IP addresses assigned to a machine, you should use WMI: Get-WMIObject win32_NetworkAdapterConfiguration |...
ExpandProperty rocks – sometimes
Select-Object will select the object properties that you want to see. So it removes all properties you did not specify, but it always returns an...
Creating Range of Letters
PowerShell can easily provide a range of numbers, but creating them is not that easy - unless you convert ascii codes into characters: 65..90 |...
Exclude Unwanted Registry Values
When you query the values of a registry key, PowerShell will add a bunch of artifacts to the results. You'll get some new properties that all...
Assignment Operators Can Get in Your Way
Have a look at this line – do you see what's wrong with it? Get-WMIObject Win32_UserAccount | Where-Object { $_.Name = 'Guest' } PowerShell will use...
Finding Services
You can use a keyword search with WMI to find a specific service. The next line will get you all services with the keyword "cert" in its...
Use Server-Side Queries
If you'd like to speed up things, you should try to filter server side instead of client side whenever you query information. For example, this...
Use $null to Identify Empty Data
You can use $null as a special variable representing "nothing." You can use it to identify (and sort out) non-existing data like so:...
Use Write-Progress to Return Feedback
Some operations will take more time so it is a good idea to return feedback. Write-Progress can do just that. Go ahead and add a Foreach-Object to...
Sending POST Data via PowerShell
Often, feedback or votes on Web pages are sent back via POST requests. You can send this kind of information via PowerShell as well. You should...
Connect or Disconnect Network Adapter
When you are ready to connect or disconnect a network adapter, you can utilize the Shell.Application COM object, which will give you access to...