Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

Welcome to the archive of tips delivered through Tobias' Tip of the Day RSS Feed and Your Power Tip of the Day email. Subscribe in the sidebar to get the latest tips!

Sort by: Most Recent | Most Viewed | Most Commented
  • WMI Device Inventory

    All PowerShell Versions The WMI service can report plenty of details about the computer hardware. Typically, each type of hardware is represented by its own WMI class. It's not easy to find out the names of such hardware classes, though. Since all...
  • Get Sleep and Hibernation Times

    All PowerShell Versions If you want to find out whether a computer is frequently put into sleep or hibernation mode, here is a function that reads the appropriate event log entries and returns a table with details, reporting when the computer was put...
  • Understanding Sequential Filtering

    All PowerShell Versions When you parse text-based log files, or need to filter other types of information, you typically use Where-Object. Here are the common scenarios that illustrate how to combine filters: # logical AND filter for ALL keywords Get...
  • Filtering Hotfix Information

    All PowerShell Versions Get-HotFix is a built-in cmdlet that returns the installed hotfixes. It has no parameter to filter on hotfix ID, though. With a cmdlet filter, you can easily focus on the hotfixes you are after. This example returns only hotfixes...
  • Getting Shutdown Information

    All PowerShell Versions Windows logs all shutdown events in its System event log. From there, you can extract and analyze the information. Here is a function that looks for the appropriate event log entries, reads the relevant information from the ReplacementStrings...
  • Copying Command History

    All PowerShell Versions If you played with PowerShell and suddenly realize that you would actually like to keep the commands you played with, try this simple one-liner: ( Get-History ) . CommandLine | clip It copies all commands from your command history...
  • Searching Files with Regular Expressions

    All PowerShell versions Get-ChildItem does not support advanced file filtering. While you can use simple wildcards, you cannot use regular expressions. To work around this, add a cmdlet filter and use the operator -match. This example will find all files...
  • Getting Files with Specific Extensions Only

    All PowerShell versions When you use Get-ChildItem to get a list of files, you may have noticed that the -Filter parameter occasionally returns more files than you’ve expected. Here is an example of this. This line does not just return files with...
  • Correcting ISE Encoding

    All PowerShell versions When you run a console application inside the ISE editor, non-standard characters such as “ä” or “ß” do not show correctly in results. To correct the encoding ISE uses to communicate with its...
  • Using the OpenFile Dialog

    PowerShell 3.0 and newer Here’s a quick function that works both in the ISE editor and the PowerShell console in PowerShell 3.0 and above): Show-OpenFileDialog. function Show-OpenFileDialog { param ( $StartFolder = [ Environment ] :: GetFolderPath...
  • Use Group-Object to Create Hash Tables

    All PowerShell versions Group-Object can pile objects up, putting objects with the same property together in one pile. This can be quite useful, especially when you ask Group-Object to return hash tables. This would generate a hash table with piles for...
  • Have PowerShell Cheer You Up!

    All PowerShell versions Writing PowerShell code is fun but can be frustrating at times. Here’s a function that makes PowerShell cheer you up. Just turn on your sound, and PowerShell will comment each command with a new remark. function prompt {...
  • Logging What a Script Does

    All PowerShell versions You probably know that in a PowerShell console (not the ISE editor), you can turn on logging: PS> Start-Transcript This will log all entered commands and all command results to a file. Unfortunately it is of limited use when...
  • A Fun Beeping Prompt

    All PowerShell versions If your computer has a sound card, here is a code snippet that will drive your colleagues nuts: function prompt { 1 . .3 | ForEach-Object { $frequency = Get-Random -Minimum 400 -Maximum 10000 $duration = Get-Random -Minimum 100...
  • Returning More Than One Value

    All PowerShell versions If a PowerShell function needs to return more than one value, best practice is to return objects, and store the information in separate object properties. Here is a simple and charming alternative for some scenarios. Simply return...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.