September 2009 - 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
  • Deleting Event Logs

    Working with event logs has become a lot easier in PowerShell v.2, and you have seen how you create and maintain your own logs. So, if you'd like to get rid of an event log, use Remove-Eventlog. But wait: this cmdlet removes any event log you specify...
  • Creating Your Own Eventlog

    In PowerShell v.2, it is very easy to create and maintain your very own event logs to track errors in your scripts or other automation solutions. It's a three-step-journey: First, create your own event log using New-Eventlog. Note that this requires...
  • Finding Events Supported by an Event Provider

    In PowerShell v.2, Get-WinEvent provides access to events written to the numerous Windows event logs. In addition, you can also examine event providers and find out which events they can actually generate: Get-WinEvent -listProvider * PowerShell * | Foreach...
  • Organizing Windows Event Logs By Source

    There are numerous Windows event logs and you now have full control using Get-WinEvent in PowerShell v.2. Instead of searching for specific event logs, you can search for specific event providers to determine which event logs they maintain. For example...
  • Handling Event Logs with Get-WinEvent

    In PowerShell v.1, Get-Eventlog would retrieve standard event log entries from event logs like "System" or "Application," but there was no way to retrieve the many special windows event logs. Inv.2, Get-WinEvent comes to the rescue...
  • Getting Process Based On Window Title

    It isn't always easy to pick the right process because the process ID or process name may not be known or ambiguous. If the process has a window and you can see the window title, all you need to do is search for a keyword in that window title. For...
  • Getting Process Windows Titles

    Get-Process retrieves all running processes and a wealth of information attached to them. One especially useful property is mainWindowTitle which holds the title string visible in the process window (if it has one). This simple line will first filter...
  • Loading New Windows 7 Modules

    Windows 7 comes with a bunch of modules that are not loaded by default. Use this to see which modules are available: Get-Module -listAvailable For example, to load a module you should use Import-Module and the module name you want to load: Import-Module...
  • Accessing Hidden Module Members

    Modules in PowerShell v.2 can declare which functions, variables, aliases etc. are public and visible to the caller and which ones are hidden. With a trick, you can also access hidden members. Let's assume you have saved the following module as example...
  • Managing PowerShell Modules

    In PowerShell v.2, all new modules work like libraries and can be loaded using Import-Module to gain access to all public functions, variables, aliases etc. like this: Import-Module path_to_module\ mymodule.psm1 A better way is to store a reference to...
  • Updating PowerShell Modules

    In a previous tip, you learned about the new modules in PowerShell v.2, which can be loaded using Import-Module. Once you have loaded a module, it is important to understand that it is cached until the PowerShell session ends. So even if you reload a...
  • Creating Script Modules

    In PowerShell v.2, there is a new feature called "module," which is a file with the extension .psm1 and behaves almost exactly like a script except for two major differences. Before you can use the functions defined in a module, you will need...
  • Trap and Try/Catch

    Trap, which has been around since PowerShell v.1, is designed to catch errors and works like this: trap { Write-Host -foregroundcolor Yellow ` "Something terrible happened: $($_.Exception.Message)" ; ` continue } & { dir nonexistent: -ErrorAction...
  • Which PowerShell Version Am I Running

    As PowerShell v.2 becomes more common , you may want to check which PowerShell version a machine is running. Use this to differentiate between v.1 and higher versions from within PowerShell: $isV2 = test-path variable:\psversiontable Check this registry...
  • Is PowerShell Available?

    As PowerShell becomes more important, you may want to automatically check whether it is available on a machine. To determine whether any PowerShell version is available, check whether this key is available: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.