November 2011 - Power Tips

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
  • Scanning Registry for ClassIDs

    The Windows Registry is a repository filled with various Windows settings. Get-ItemProperty can read Registry values and accepts wildcards. So, with Get-ItemProperty, you can create tools to find and extract Registry information. For example, if you know...
  • Creating PowerShell Menus

    PowerShell is console based, so its default menus are console based as well. To offer choices to your users, here is some sample code to create a simple menu: $title = "Reboot System Now" $message = "Do you want to reboot your machine now...
  • Using Wildcards with Environment Variables

    You can use the env: PowerShell drive to list all Windows environment variables like this: PS > Dir env : * user * Name Value ---- ----- USERNAME w7-pc9 USERPROFILE C:\Users\w7-pc9 ALLUSERSPROFILE C:\ProgramData USERDOMAIN DEMO5 To access the content...
  • Permanently Changing User Environment Variables

    To create or change an environment variable in the user context, use this low-level call: [ environment ] :: SetEnvironmentVariable ( ' Test ' , 12 , ' User ' ) This environment variable will keep the value until you change it or delete...
  • Using Regular Expressions with Dir

    When you use Dir (alias: Get-ChildItem) to list folder contents, you can use simple wildcards but they do not give you much control. A much more powerful approach is to use regular expressions. Since Get-ChildItem does not support regular expressions...
  • Formatting Currencies

    Formatting numbers as currencies is straight-forward - as long as it is your own currency format: ' {0:C} ' -f 12.22 If you want to output currencies in other cultures, you still can do it. Let's assume you created a currency converter and...
  • Closing Excel Gracefully

    When you access Microsoft Excel from script, you may have noticed that it never gets removed from memory again, even if you call its Quit() method: ' Excel processes: {0} ' -f @ ( Get-Process excel -ea 0 ) . Count $excel = New-Object -ComObject...
Copyright 2012 PowerShell.com. All rights reserved.