March 2010 - Power Tips

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell


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
  • Read Registry Values

    You will find that reading Registry values is not always easy because the Registry is accessible only via the generic "drive" paradigm. Here is a function you can use to read registry values: Function Get-RegistryValue ( $key , $value ) { Get...
  • Resolve Paths Gets Lists of Paths

    You can use Resolve-Path to support wildcards so you can use it to easily put together a list of file names like this: Resolve-Path $env:windir \ * . log ReTweet this Tip!
  • Adding New Virtual Drives

    You do not need to use drive letters to access information provided by PowerShell providers. For example, you should use this to list the HKEY_CLASSES_ROOT you have in your registry: Dir Registry:: HKEY_CLASSES_ROOT By pre-pending the path with the provider...
  • ExpandProperty to the Rescue

    You will find that Select-Object is often used to select object properties and discard unneeded information: Get-Process | Select-Object Name, Company In addition, Select-Object also does another important job by replacing the original object with one...
  • Open Explorer

    While the PowerShell console is great, it is sometimes just easier to switch to Windows Explorer. Here is the fastest way to open Explorer and show the current folder you are using in your PowerShell console goes: ii . ReTweet this Tip!
  • Exchange 2010 Compiled Help

    Want to learn about all the new Exchange 2010 cmdlets? You can download the compiled Help file from Microsoft: ReTweet this Tip!
  • Discovering Impact Level

    In a previous tip, you learned how to use $ConfirmPreference to get a warning before a cmdlet actually changes your system. This was based on the impact level that a cmdlet declares. There is no obvious way to determine the impact level of cmdlets. Here...
  • How ConfirmPreference works

    Cmdlet authors can judge how severe the action is a cmdlet takes and choose from Low over Medium to High. You can use the variable $ConfirmPreference to set the level at which you would like to be warned before a cmdlet actually does something. By default...
  • Hide Error Messages

    You may already know that you can suppress error messages with the ErrorAction parameter, which is often a good idea. Take a look at this and then try the line with and without ErrorAction: dir $env:windir * . log -Recurse -ErrorAction SilentlyContinue...
  • Temporary File Name

    Thanks to Get-Date, you can easily create unique temporary file names with a timestamp: ( Get-Date -format 'yyyy-MM-dd hh-mm-ss' ) + '.tmp'
  • Parameters Correspond to Columns

    Many Get-*-Cmdlets, such as Get-EventLog or Get-Process, will output data in columns and support parameters named like these columns. So to filter the results, you should just look at the column you want to filter on, then use the parameter named like...
  • Use Culture-Specific Dates!

    PowerShell always uses a culture-neutral approach when you implicitly convert a date. So this does not necessarily work with your own culture. [ DateTime ] '24.1.2010' Instead, a culture-aware way is to use the -as operator: '24.1.2010'...
  • Export CSV with Culture-Specific Delimiter

    Export-CSV used to only support the comma as separator, which caused problems on non-U.S.-systems. In PowerShell v.2, with -useCulture you can have Export-CSV use whatever delimiter is the right one, depending on your culture. There is only one caveat...
  • Stopping the Pipeline

    Usually, once a pipeline runs, you cannot stop it prematurely, even if you already received the information you were seeking. Simply use this filter to stop a pipeline: filter Stop-Pipeline ([ scriptblock ] $condition = { $true }) { $_ if ( & $condition...
  • Creating Large Dummy Files With .NET

    You can always resort to the underlying .NET framework whenever the functionality you need isn't available through a cmdlet. The following code is a very fast way to generate really large test files: $path = "$env:temp\testfile.txt" $file...
1 2 Next >
Copyright 2012 All rights reserved.