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
  • Creating Range of Letters

    PowerShell can easily provide a range of numbers, but creating them is not that easy - unless you convert ascii codes into characters: 65..90 | Foreach-Object { "$([char]$_):" } ReTweet this Tip!
  • Exclude Unwanted Registry Values

    When you query the values of a registry key, PowerShell will add a bunch of artifacts to the results. You'll get some new properties that all start with "PS": $regkey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' Get-ItemProperty...
  • Assignment Operators Can Get in Your Way

    Have a look at this line – do you see what's wrong with it? Get-WMIObject Win32_UserAccount | Where-Object { $_ . Name = 'Guest' } PowerShell will use different operators for assignment and equality. So you may run into these issues...
  • Finding Services

    You can use a keyword search with WMI to find a specific service. The next line will get you all services with the keyword "cert" in its description: Get-WmiObject win32_service - Filter 'Description like "%cert%"' | Select...
  • Use Server-Side Queries

    If you'd like to speed up things, you should try to filter server side instead of client side whenever you query information. For example, this line will get you all warnings from an event log: Get-EventLog System | Where-Object { $_ . EntryType ...
  • Use $null to Identify Empty Data

    You can use $null as a special variable representing "nothing." You can use it to identify (and sort out) non-existing data like so: Get-Process | Where-Object { $_ . Company -ne $null } | Select-Object Name, Company If you still get processes...
  • Use Write-Progress to Return Feedback

    Some operations will take more time so it is a good idea to return feedback. Write-Progress can do just that. Go ahead and add a Foreach-Object to your pipeline, update the progress information with it, and remember to return the data received by Foreach...
  • Sending POST Data via PowerShell

    Often, feedback or votes on Web pages are sent back via POST requests. You can send this kind of information via PowerShell as well. You should simply create a POST request with the target URL and the desired parameters/information and send it off: $url...
  • Connect or Disconnect Network Adapter

    When you are ready to connect or disconnect a network adapter, you can utilize the Shell.Application COM object, which will give you access to context menu items. $sa = New-Object -ComObject Shell.Application $conn = $sa . NameSpace (49). Items () | ...
  • Finding 10 Largest Files

    You may need to find the largest files for possible clean-up when free space on a drive runs low. One way is to have PowerShell examine all file sizes, sort by file size descending, and then pick the 10 largest ones (the 10 first results): Dir $home ...
  • Random Tip of the Day

    Get-Random has a dual purpose. It can provide you with a random number and also pick random elements from a collection. So, if you want to get a new random PowerShell "Tip of the Day," you should try this: Get-Help about_ * | Get-Random | Out...
  • Sorting Stuff

    You can use Sort-Object to sort simple variable types. Have a look at the following: 'Tom' , 'Chris' , 'Judy' , 'Alan' | Sort-Object Input can come from a different command. If you’d like to get seven random lottery...
  • Finding Invalid Aliases

    When you create new Aliases with Set-Alias, PowerShell does not check whether the target you specify is valid. Instead, this is checked only when you use the alias. This line can help you to find all aliases with invalid targets: Get-Alias | ForEach-Object...
  • IPv4 Address Lists

    You should try this to get all IPv4 addresses assigned to your system: Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object { $_ . IPEnabled -eq $true } | Foreach-Object { $_ . IPAddress } | Foreach-Object { [ IPAddress ] $_ } | Where-Object...
  • Getting Assigned IP Addresses

    You should use this to retrieve all IP addresses assigned to your computer: Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object { $_ . IPEnabled -eq $true } | Foreach-Object { $_ . IPAddress } Get-WMIObject win32_NetworkAdapterConfiguration...
« First ... < Previous 72 73 74 75 76 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.