Wouldn't it be fun if you could send results directly to the clipboard? Well, beginning with Windows Vista you can - thanks to clip.exe: PS>...
Powershell
Spying on Parameters
Your own PowerShell functions can have the same sophisticated parameters, parameter types and parameter sets that you know from cmdlets. However, it...
Removing Shares (Remotely, Too)
In a previous tip you learned how you can create ad-hoc shares using WMI. These shares persist until you remove them again. So if you'd like to...
Creating Shares Remotely
Let's assume you need to access another machine's file system but there is no network share available. Provided you have local administrator...
Opening MsgBoxes
Need a quick message box to display something or ask a question? Fortunately, PowerShell can access old COM components. Here's a line that...
Creating a "Better" More
In a previous tip you learned that using "more" to paginate output can be dangerous, and instead you should use Out-Host -Paging. To...
"More" Can Be Dangerous – Use Better Alternative
You might know the more.com tool: when you pipe output to more.com, the output is displayed page by page: PS> Get-EventLog -LogName System | more...
Creating Your Own Get-Driver Tool
Some code snippets are really valuable, so you should turn them into functions to keep around as new PowerShell commands. Here's a sample...
Finding More Driver Information
In a previous tip you learned how you can convert raw CSV data from a console application such as driverquery.exe into real PS objects. Let's...
Finding Driver Information
driverquery.exe returns all kinds of information about installed drivers, but the information seems a bit useless at first: PS> driverquery.exe...
Finding Standard Parameter Names
In a previous tip, we suggested you to use standard parameter names for your own functions. To get a feeling for what the parameter names are that...
Best Practice for PowerShell Functions
This is a best-practice message: when you create your own function, here are some things you should consider: - Function name: use cmdlet naming...
Adding New Lines to Strings
In a previous tip you learned that text arrays can easily be multiplied. The same is true for assignment operators such as +=. When you apply this...
Creating Multiline Strings
You probably know what this line produces: 'Hello' * 12 Right, you get 12 times the string you submitted. If you wanted new lines instead, a...
Enumerating Registry Keys
To enumerate all subkeys in a Registry key, you might be using a line like this: PS> Dir...
Asking for Credentials
When you write functions that accept credentials as parameters, add a transformation attribute! This way, the user can either submit a credential...
How to List Registry Hives
Use the provider name instead of a drive name when you need to get a list of all registry hives: Dir Registry:: ReTweet this Tip!
Writing Registry Key Default Values
If you need to set the default value for a registry key, you can use either of these approaches: Set-ItemProperty -Path HKCU:\Software\Somekey -Name...
Use Dumping Help
You can start by dumping all Help information into a file to learn more about a PowerShell cmdlet. You can then read all details about the cmdlet...
Use Out-GridView Requirements
Out-GridView is a great way to present results in a “mini-Excel” sheet: Get-Process | Out-GridView However, Out-GridView has two...
Use the CTRL+Arrow
Inside the PowerShell console, you can hold CTRL while pressing the arrow key to move the cursor word-by-word. This way, you can move the cursor...
Change Service Start Mode the PowerShell Way
When you list services with Get-Service, you will find that a lot of properties may seem to be missing. You can still set such properties when you...
Change Service Startmode
You can use WMI like this if you want to change a service start mode: ([wmi]'Win32_Service.Name="Spooler"').ChangeStartMode('Automatic').ReturnValue...
Determining Service Start Modes
By using WMI, you can enumerate the start mode that you want your services to use. To get a list of all services, try this: Get-WMIObject...