Power Tips

Share |

Join PowerShell.com!
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
  • Forget the "Finally"-Block

    When you handle errors using try/catch/finally, you may wonder what the finally block is for. Here is a demo: try { dir nonexisting:\ -ErrorAction Stop } catch { "Error Occured: $_" } finally { ' Doing Cleanup ' } Whenever a non-terminating...
  • Understanding and Handling Terminating Errors

    To suppress errors in a cmdlet, you can use the common parameter -ErrorAction SilentlyContinue. Here is a sample: Get-WmiObject Win32_BIOS -ComputerName localhost , offline , 127.0.0.1 -ErrorAction SilentlyContinue | Select-Object __Server , Manufacturer...
  • Use "E" in Numbers

    To quickly define large integers, use the keyword "E" inside your number: PS > 64E6 64000000 ReTweet this Tip! http://bit.ly/pGRrMP
  • Executing PowerShell Commands with Full Privileges

    If a script needs to run only particular commands with full Administrator privileges, you can run those in a separate elevated shell. $code = "md $env:windir\newfolder | Out-Null" if (( Test-Path $env:windir\newfolder) -eq $false ) { Start-Process...
  • Running Script with Full Privileges

    On UAC-enabled systems, to make sure a script is running with full admin privileges, add this code at the beginning of your script: param ([ switch ] $Elevated ) function Test-Admin { $currentUser = New-Object Security.Principal.WindowsPrincipal $ ([...
  • Getting Information about Speed Traps and Traffic Jams

    PowerShell can read RSS feeds in just a couple of lines of code. Many radio broadcasters maintain RSS feeds with information about speed traps and traffic conditions. Here is a (German) sample of how you can access and display such information via PowerShell...
  • Text-to-Speech

    Here is a fun function that converts text to speech. It even has a switch parameter called -Drunk to change the voice accordingly: function Out-Text { param ( [ Parameter ( Mandatory = $true )] $Text , [ switch ] $Drunk ) $object = New-Object -ComObject...
  • Latest Process Activity

    To find out whether a computer is idling for a long time or actually doing something, here is a function that returns the last process that was recently started, including the time in minutes and days it has been running and its description: function...
  • Getting NIC IP addresses and MAC addresses

    WMI can return network information such as your current IP address and MAC address. Here is a sample how PowerShell can utilize and beautify the information. The result is a table with all network adapters that have a MAC address, neatly displaying IPv4...
  • Checking Windows Updates Remotely

    In a previous tip you learned how to list installed Windows Updates. Unfortunately, this only works for local machines. Provided you have enabled PowerShell Remoting in your infrastructure, here is a sample that enables you to retrieve the information...
  • Controlling PSComputerName in Remoting Data

    Whenever you use Invoke-Command to remotely execute code, you will notice that PowerShell automatically adds the column PSComputerName to your results. That's great because when you run Invoke-Command against more than one computer, you want to still...
  • Listing Windows Updates

    There is a not widely known COM object that you can use to list all the installed Windows Updates on a machine. Here is the code: $Session = New-Object -ComObject Microsoft.Update.Session $Searcher = $Session . CreateUpdateSearcher () $HistoryCount =...
  • Determine Functions Pipeline Position

    Assume your function wanted to know whether it is the last element in a pipeline or operating in the middle of it. Here is a way for a function to determine its current pipeline position: function test { param ( [ Parameter ( ValueFromPipeline = $true...
  • Displaying Balloon Tip

    Let's assume your script wants to share status information via a balloon message in the system tray area. Here is a sample: [ system.Reflection.Assembly ] :: LoadWithPartialName ( ' System.Windows.Forms ' ) | Out-Null $balloon = New-Object...
  • Extracting Icons

    To extract an icon from a file, use .NET Framework methods. Here is a sample that extracts all icons from all exe files in your Windows folder (or one of its subfolders) and puts them into a separate folder: [ System.Reflection.Assembly ] :: LoadWithPartialName...
« First ... < Previous 59 60 61 62 63 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.