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
  • Split Special Characters

    PowerShell’s new –split operator can split text into parts. Usually, you will submit a delimiter character to tell –split where to split: PS > "1,2,3,4" -split "," 1 2 3 4 However, you can also submit a script...
  • Use Hash Tables To Convert Numeric Return Values

    You can use Hash Tables to translate individual return values to clear text. This example shows you how to convert return codes 0 and 5 to some clear text representation: $cleartext = @ { 0 = ‘ success ’ 5 = ‘ access denied ’ ...
  • Learn About Operators

    Operators are an important part of the PowerShell language. Try this to learn more about them: Help operators This will list all the different kinds of operators. For example, you will need comparison operators if you want to create conditions. You can...
  • Filter PowerShell Results Fast and Text-Based

    Take a look at this simple filter called grep: filter grep ( $keyword ) { if ( ( $_ | Out-String ) -like "*$keyword*" ) { $_ } } And here are some samples showing how easy it is to filter results using plain text keywords: PS > Get-Service...
  • Use Sort-Object With Better DataTypes

    This line of code will sort system DLLs based on file version. However, it turns out that it sorts incorrectly: dir $env:windir\system32 -filter * . dll | ` Select-Object -ExpandProperty VersionInfo | ` Select-Object FileName , ProductVersion | Sort-Object...
  • Output Data in Color

    When you pipe results to Write-Host to output them in color, you may be in for a surprise: Get-Process | Write-Host -ForegroundColor Yellow The result is colorized, but Write-Host has converted the processes into very simplistic string representations...
  • Resolve IP-Addresses

    This one-liner accepts one or more IP-addresses and will try to resolve the address. If DNS returns valid information, you will receive the host name and aliases. If not, you will get a warning with the cause: ' 127.0.0.1 ' , ' 127.0.0.2 '...
  • Be Careful With Strict-Mode!

    You will discover that PowerShell is production-oriented. So, if you specify object properties that do not exist, you will simply get back "nothing": $Host . LetsSee This is bad because you will not get a warning if you mistype a property name...
  • Find True Property Names

    Sometimes, the column names you see when you run cmdlets do not really correspond with the true object property names. For example, Get-Process will create a column named "CPU(s)," and Get-EventLog will display a column named "Time."...
  • Wait For a Program to Finish

    You should use Start-Process and its -Wait parameter if you want to force PowerShell to wait for a program to finish before it continues: Start-Process notepad -Wait This will cause PowerShell to suspend until you close Notepad. You should access the...
  • Analyzing Windows Launch Time

    Beginning with Windows Vista/Server 2008, you can get rich information about your machine from the new additional application and service logs that are accessible by Get-WinEvent. You should have a look at the function Get-WindowsLaunch. It will tell...
  • Use Where-Object to Filter Results

    You can always use Where-Object when you need to filter results. This cmdlet expects a filter script to determine the results you want. Here are some examples: Try this to find only files greater than 1MB: dir $env:windir | Where-Object { $_ . Length...
  • Getting AD Terminal Server Settings

    On client operating systems, such as Windows 7, there are some Support libraries missing that you will need to display terminal server settings stored in the AD. So when you query a user in your AD, all terminal server settings will be missing or blank...
  • 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 Value

    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 ‘ ( Default ) ’ -Value MyValue Or, you can just do this: Set-Item -Path HKCU:\Software\Somekey...
« First ... < Previous 57 58 59 60 61 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.