Often, it is necessary to output numbers, but you may want to control the number of digits and would like to control the formatting. The -f operator...
database-tools
Sending Results to Excel
Here's a little function called Out-ExcelReport. Just pipe anything to it, and it will open in Microsoft Excel - provided it is installed on...
Unix Log Scanner
After the installation of the Unix Log Scanner using the uptime plugin manager I try to create a service monitor. But every time I run the test I...
Colors Become Even More Important in the New ISE Editor
When you type in code into the new PowerShell 3.0 ISE editor, your code is not just "colorful". You may know that each color stands for a specific...
Controlling Process Priority and Processor Affinity
When you get yourself a process using Get-Process, what you get back is an object that has useful methods and writeable properties. This line will...
Executing Elevated PowerShell Code
Sometimes, a script may want to execute some portion of its code elevated, for example to write to HKLM in the Registry or change protected...
Examine Parameter Binding
PowerShell caters all tastes which is why the next two lines do the exact same thing and get all JPG pictures from your Windows folder: PS>...
Show-Command Creates PowerShell-Code for You
In PowerShell 3.0, there is a cool new cmdlet called Show-Command: PS> Show-Command Get-Process It works both in the console and the ISE editor,...
Blocking Interactive Console Apps in the ISE editor
The ISE editor in PowerShell 3.0 seems to have an interactive console, but it really isn't. It is just a simulated console. So any command that...
Multiline-Input in ISE Editor
If you'd like to enter long lines of code into the console panel in the new PowerShell 3.0 ISE, you can press SHIFT+ENTER. This will add a line...
Kindergarten-Mode
To protect you from damages while playing with PowerShell on a productive system, set the ”WhatIf” mode as default:...
Combining Objects
Sometimes it becomes necessary to consolidate two or more objects into one. So, how would you combine object properties into one object? In a...
Using CIM Cmdlets Against PowerShell 2.0
As you may have read, in PowerShell 3.0, there is a new family of cmdlets designed to improve the way we work with WMI. The powerful Get-WmiObject...
Finding Newest or Oldest Files
In PowerShell 3.0, Measure-Object can be applied not just to numeric data but to anything that is comparable. In PowerShell 2.0, this line would...
NULL values have a Count property
In a previous tip we explained that in PowerShell 3.0, every object has a Count property now. This even includes null values: PS> $null.Count 0...
Displaying Object Standard Properties (Nicely)
In a previous tip, we explained how you can add a custom data type to your own custom objects that you might want to return from a function, and...
"Count" Available in PowerShell 3.0
Finally, the property Count is available on all objects in PowerShell 3.0. This solves a great problem because it allows you to count results even...
Removing Empty Object Properties (All Versions)
In a previous tip we showed how you can remove all empty properties from an object and also sort its properties alphabetically. The code required...
Removing Empty Object Properties
Objects hold a lot of information and often, properties can also have null values. To reduce an object to only those properties that actually have a...
Controlling Object Property Display
When you create functions that return custom objects, there is no way for you to declare which functions should display by default. PowerShell...
Logging Input Commands
If you'd like to maintain a log file with all the commands you entered interactively - in the PowerShell console as well as in the ISE editor -...
Creating Objects in PowerShell 3.0 (Fast and Easy)
In PowerShell 3.0, you can cast a hash table to a PSCustomObject type to easily generate your own objects: $content = @{ Name="Weltner"...
Protecting Functions
To prevent a function to be redefined or overwritten, you can write-protect it: function Test-Function { 'Hello World!' } Set-Item -Path...
Creating New Objects the JSON way
There are numerous ways how you can create new objects that you may use to return results from your functions. One way is using JSON, a very simple...