There is a not widely known COM object that you can use to list all the installed Windows Updates on a machine. Here is the code: $Session =...
Powershell
Determine Functions Pipeline Position with PowerShell
Assume your function wanted to know whether it is the last element in a pipeline or operating in the middle of it. Here is a way for a function to...
Displaying Balloon Tips with PowerShell
Let's assume your script wants to share status information via a balloon message in the system tray area. Here is a sample:...
Saving History to Script with PowerShell
PowerShell is all about trial and error, and when you want to save your interactive input to a script file, this is how it could be done:...
Forwarding Selected Parameters with PowerShell
In a previous tip you learned how you can forward function parameters to cmdlets. But what if you just want to forward some of the parameters? Here...
Clean Your Temp Folder with PowerShell
When disk space gets low, you may want to clean up your temporary folder. The code deletes all files that are older than 30 days to make sure...
Filtering Files or Folders with PowerShell
To filter folder content by file or folder, check whether the Length property is present. It is present for files and missing in folders: Dir...
Office365 Cmdlets with PowerShell
Office365 comes with a complete set of PowerShell cmdlets. To review the cmdlets and what you can do with them, visit this URL:...
Use Select-String with Context in PowerShell
Select-String can find lines with a specific keyword. It can also include context-relevant lines before and after that line. This will filter the...
Launching Applications with PowerShell
When you launch *.exe-applications with arguments, you may get exceptions because PowerShell may misinterpret the arguments. A better way to do this...
Managing File System Tasks with PowerShell
If you need to list all cmdlets that deal with file system-related tasks, try this: Get-Command -Noun item*, path Many of these cmdlets have...
Appending CSV Data with PowerShell
To append a CSV file with new data, first of all make sure the type of data you append is the same type of data already in a file (or else column...
Create CSV without Header using PowerShell
ConvertTo-CSV can create comma separated values (CSV) on the fly but it always adds a new header. To create CSV data without columns, take a look at...
Checking Array Content with Wildcards in PowerShell
In a previous tip we illustrated how -like can work on array. To iterate on that, check out how -like (in contrast to -contains) allows the use of...
Assigning Two Unique Random Numbers in PowerShell
If you need to get two random numbers from a given numeric range, and you want to make sure they cannot be the same, simply tell Get-Random to pick...
Eliminating Empty Text in PowerShell
If you wanted to exclude results with empty (text) columns, you can filter based on $null values. This will get you all processes with a valid...
Adding Personal Drives in PowerShell
In a previous tip we showed you how you can add new drives to easily access your desktop, your cookies or media like music and video. However, when...
When to Use Select-Object’s -ExpandProperty in PowerShell
Use Select-Object to determine which information in a result you are interested in. Here are three easy rules for its parameters: Use -Property *...
Find WMI Classes with PowerShell
In a previous tip we showed how Get-WmiObject can search for WMI class names. Some of the returned WMI class names aren't particularly useful,...
Finding Files Only or Folders Only
In PowerShell v2, to list only files or only folders you had to do filtering yourself: Get-ChildItem $env:windir | Where-Object { $_.PSIsContainer...
Export-Csv with Append
Finally, in PowerShell v3 the cmdlet Export-Csv got a new parameter called -Append! Now you can easily append information to an existing CSV file....
New Alias in PowerShell v3
Since Select-String is such a useful cmdlet, the PowerShell decided to add an alias to it in PowerShell v3. The alias is called sls. Try this:...
Sharing PowerShell ISE v3 Code Snippets
In a previous tip we illustrated how you can create code snippets for PowerShell ISE v3 script editor using New-ISESnippet. All custom snippets are...
Sophisticated Directory Filtering in PowerShell v3
In PowerShell v3, Get-ChildItem now supports sophisticated filtering through its –Attribute parameter. To get all files in your Windows folder...