April 2010 - 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
  • 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...
  • Generate PC Lists

    One easy way of creating lists of PC names or IP address ranges etc is a simple pipeline like this: 1..40 | Foreach-Object { 'PC-W7-A{0:000}' -f $_ } Use the -f operator to format the number. In this example, it will always be three-digit. ReTweet...
  • Create HTA Files

    Another way is to ConvertTo-HTML is a convenient way of converting object results in HTML. However when you open these files, your browser starts with all the bells and whistles. You should try a better way by storing the HTML in a file with HTA extension...
  • WMI Server Side Filtering

    Whenever you use Get-WMIObject, be sure to minimize resources and maximize speed by using server-side filtering. The next line will use the slow client-side filtering with Where-Object: Get-WMIObject Win32_Service | ? { $_ . started -eq $false } | ? ...
  • List Installed Updates

    Using Get-Hotfix is pretty convenient as it serves to list installed updates. Unfortunately, it is not very thorough as it doesn’t retrieve information about tons of minor updates. The complete list can be found in a file called windowsupdate.log...
  • Downloading Files Silently in the Background

    When using the additional cmdlets in the BitsTransfer module that comes with Windows 7 and Server 2008 R2, you can make downloads happen silently in the background so you do not need to wait for them. The next lines will download a tutorial video in the...
  • Download Files from the Internet

    Windows 7 and Server 2008 R2 come with a module called BitsTransfer, which allows you to access the background intelligent transfer service used by Windows Update. With it, you can download files from the Internet. The next lines will download a tutorial...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.