April 2012 - 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
  • Executing PowerShell on Computer Lock

    PowerShell can respond to system events such as locking or unlocking a session. Here is a fun sample. Provided you have your sound card turned on, your computer will say good-bye when you press WIN+L and welcome you back when you log on again: function...
  • Getting Windows Product Key

    Ever wanted to read out the Windows license key? In the Windows Registry, this key is present, but it is stored as a digital ID. To convert it back to the license key used to originally license the product, try this function. It uses some serious math...
  • Using "Elevator Music" In Your Scripts

    Maybe you'd like to give some feedback to the users of your script while it processes a long-running task. One of the easiest (and most annoying) types of feedback is to play some "elevator music". Here's how: function Start-ElevatorMusic...
  • Adding Progress to Long-Running Cmdlets

    Sometimes cmdlets take some time, and unless they emit data, the user gets no feedback. Here are three examples for calls that take a long time without providing user feedback: $hotfix = Get-Hotfix $products = Get-WmiObject Win32_Product $scripts = Get...
  • Output Scheduled Tasks to XML

    Here's an easy way how you can export and dump a task that you created in "Scheduled Tasks" to XML: function Export-ScheduledTask { param ( [ Parameter ( Mandatory = $true )] $TaskName , [ Parameter ( Mandatory = $true )] $XMLFileName )...
  • Creating Scheduled Tasks From XML

    In a previous tip, we showed how you can export a scheduled task to an XML file. Now, it's time to see how you can re-import that XML file to re-create the scheduled task. Before you can use this tip, you need an XML definition for a task. Check out...
  • Listing Processes and Process Ownership

    Get-Process can list processes but does not provide information about who is running the process. Here, WMI can help. Get-ProcessEx is a clever function that returns process information including ownership, and it works remotely, too. So if you wanted...
  • Killing Long-Running Scripts

    You can use a background thread to monitor how long a script is running, and then kill that script if it takes too long. You can even write to an event log or send off a mail before the script is killed. Here's how you implement such a time bomb:...
  • Home-Made Driver Query Tool

    Some months ago we introduced to you the driverquery.exe tool and how to convert its output to PowerShell objects. Here's now an amazing function that turns this command-line tool into a graphical tool that lists drivers from both local and remote...
  • Making Names Unique

    To make a list of items or names unique, you could use grouping and then, when a group has more than one item, append a numbered suffix to these items. Here's a simple example: function Convert - Unique ( $list ) { $list | Group-Object | ForEach-Object...
  • Verbose Driver Information

    In a previous tip you discovered driverquery.exe to list driver information. This tool sports a /V switch for even more verbose information. However, due to localization errors, when you specify /V, column names may no longer be unique. That's when...
  • Finding Numbers in Text

    Regular Expressions are a great help in identifying and extracting data from text. Here's an example that finds and extracts a number that ends with a comma: PS > $text = "I am looking for a number like this 67868683468932689223479, that is...
  • Converting Bitmaps to Icons

    If you need a new icon and have no icon editor at hand, then you can take a bitmap file (create one with MS Paint if you must) and have PowerShell convert it into an icon file. The function code also illustrates how you can open an Explorer window and...
  • Use Internet Connection with Default Proxy

    If you want PowerShell to use the same proxy settings that are set in your Internet Explorer browser, then here's the code you need: $proxy = [ System.Net.WebRequest ] :: GetSystemWebProxy () $proxy . Credentials = [ System.Net.CredentialCache ] ...
  • Sending Email to Multiple Recipients

    Send-MailMessage can send emails to multiple recipients. You just need to make sure the list of recipients is provided as an array. When you call Send-MailMessage via command line, that's a no-brainer. Simply use a comma-separated list: PS > Send...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.