Power Tips

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
  • Network Segment Scan

    In a previous tip, we created a Check-Online filter to eliminate offline systems from a list of IP addresses and computer names. Now, find out what you can do with that! For example, try to auto-generate IP-addresses for a network segment and return host...
  • Creating Custom Objects

    PowerShell v.2 has a new trick for creating your very own objects that you can then pass to other cmdlets. It is a two-step process. First, create a hash table and add all the information you want in your object: $hash = @{} $hash . name = "Tobias"...
  • Use the Force!

    Many cmdlets support the -force switch parameter. With it, the cmdlet will do more than usual. What exactly -force does depends on the cmdlet. For example, Get-Childitem (aka Dir) by default does not list hidden files. However, with -force, it does. Another...
  • Childproofing PowerShell

    If you are new to PowerShell, you may be worried about causing unwanted damage or change. One way of childproofing PowerShell is by changing the whatif-default like so: $whatifpreference = $true From now on, any cmdlet supporting the -whatif parameter...
  • Is PowerShell Available?

    As PowerShell becomes more important, you may want to automatically check whether it is available on a machine. To determine whether any PowerShell version is available, check whether this key is available: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell...
  • Download Files With BITS

    Windows 7 comes with a new module called BitsTransfer. This allows you to schedule downloads so they can download in the background using the BITS service. The main advantage is that BITS can download even large files dependably because it can resume...
  • Ping and Range Ping

    In PowerShell, you can access .NET methods directly so it is easy to add a ping functionality: $object = New-Object system.Net.NetworkInformation.Ping $object . Send ( '127.0.0.1' ) You can wrap it as function to get even more out of this: function...
  • Using COM Objects to Say "Hi!"

    If you have ever written scripts using VBScript, you probably know COM objects which are DLLs and work like command libraries. You can use COM objects in PowerShell, too. Simply use New-Object and the parameter -COMObject to instantiate the COM library...
  • Stopping and Disabling Services

    You may find that Vista's new Instant Search can sometimes get out of hand and slow down your machine. Temporarily disabling and then stopping the search service is one way to deal with this issue: Set-Service wsearch -startupType Disabled Stop-Service...
  • Accessing Internet Explorer

    Accessing Internet Explorer can be useful for obtaining Web content. The usual approach uses a COM object called InternetExplorer.Application like this: $ie = New-Object -comObject InternetExplorer.Application $ie . visible = $true $ie . navigate ( 'http...
  • Checking File and Folder Permissions

    Get-Acl is a convenient Cmdlet to expose NTFS file and folder settings. For example, to get a list of ownerships for a folder content, do this: Dir | Get-Acl To find out which "Identities" (Users or groups) have specific permissions granted...
  • List All Group Memberships of Current User

    In case you need to get a list of all of your current Group memberships as derived from your current access token, use this line: ([ System.Security.Principal.WindowsIdentity ]:: GetCurrent ()). Groups | Foreach-Object { $_ . Translate ([ System.Security...
  • 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...
  • 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 ...
  • 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...
« First ... < Previous 3 4 5 6 7 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.