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
  • Launching Applications with Alternate Credentials

    If you must run an application with a different identity, Start-Process offers the parameter -Credential. This would launch the Notepad editor using the context of user mydomain\myuser: Start-Process -FilePath notepad -Credential mydomain\myuser However...
  • Unzipping Files

    Unfortunately, there is no built-in cmdlet to unzip files. There are plenty of 3rd party tools, many of which are free. If you cannot use these tools, here's how native Windows components can unzip files, too. Note that this requires the built-in...
  • Playing WAV files

    PowerShell can play WAV files, so you can add sound and special effects to your scripts (provided your system has a sound card): PS > $player = New-Object System.Media.SoundPlayer " $env:windir\Media\notify.wav " PS > $player . Play (...
  • Creating a "Better" More

    In a previous tip you learned that using "more" to paginate output can be dangerous, and instead you should use Out-Host -Paging. To "update" more.com and make it behave like Out-Host with the -Paging parameter set, use a proxy function...
  • 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...
  • 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...
  • Getting Network Adapter Settings

    To view the configuration details of a network adapter, you can specify the network adapter connection ID as it appears in your control panel. By linking the WMI result to the corresponding Win32_NetworkAdapterConfiguration class, you get to the actual...
  • Combining Network Adapter Information

    In a previous tip you learned that WMI network adapter information is separated into two classes. Win32_NetworkAdapter represents the hardware, and Win32_NetworkAdapterConfiguration contains the configuration details. To mix information from both classes...
  • Setting Mouse Position

    PowerShell can place the mouse cursor anywhere on your screen. Here's the code: [ system.Reflection.Assembly ]:: LoadWithPartialName ( "Microsoft.Forms" ) | Out-Null [ System.Windows.Forms.Cursor ]:: Position = New-Object System.Drawing...
  • Create Random Passwords

    Whenever you need to create a new random password, be sure to check out this function: function Get-RandomPassword { param ( $length = 10, $characters = 'abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789!"§$%&/()=?*+#_' ) # select...
  • Find Latest Processes

    You should try this piece of code to find all processes that were started within the past 10 minutes: Get-Process | Where-Object { try { ( New-Timespan $_ . StartTime ) . TotalMinutes -le 10 } catch { $false } } This will only cover processes that you...
  • Adding Protection to Functions

    Functions that you define are read/write and can easily be overwritten. You can set the read-only attribute to make a function read-only so that you get a warning if you try to overwrite it. This line sets the read-only attribute for a function named...
  • Test whether Registry Value exists

    You should remember that registry values are treated like properties to a registry key so they have no specific path and you cannot use Test-Path to check whether a given registry value exists. Here is a function you can use instead: Function Test-RegistryValue...
  • Exchange 2010 Compiled Help

    Want to learn about all the new Exchange 2010 cmdlets? You can download the compiled Help file from Microsoft: http://www.microsoft.com/downloads/details.aspx?FamilyID=045f7af5-b226-4a05-8ace-4e17cfdef856&displaylang=en ReTweet this Tip!
  • Comparing Results

    PowerShell makes it easy to compare results and find only things that changed. For example, you may want to list only processes that started after a given time. To do that, first create the initial snapshot of running processes. Then, at a later time...
« First ... < Previous 3 4 5 6 7 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.