July 2010 - 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
  • Getting Help on WMI Methods

    Have you ever wanted to get a list of all WMI methods present inside a specific WMI class – plus a meaningful description and a list of all the supported return values? Here is how: $class = [ wmiclass ] "Win32_NetworkAdapterConfiguration"...
  • Renewing all DHCP Leases

    Some WMI classes contain static methods. Static methods do not require an instance. ([ wmiclass ] "Win32_NetworkAdapterConfiguration" ). RenewDHCPLeaseAll (). ReturnValue ReTweet this Tip!
  • Calling ChkDsk via WMI

    Some WMI classes contain methods that you can call to invoke some action. For example, the next line initiates a disk check on drive D: ([ wmi ] "Win32_LogicalDisk='D:'" ). Chkdsk ( $true , $false , $false , $false , $false , $true ...
  • Getting Help for WMI Classes

    In a previous tip, you discovered how to search for WMI classes like Win32_VideoController. Now, what exactly is the purpose of this class? You can retrieve Help information for any WMI class with the next lines of code,: $class = [ wmiclass ] 'Win32_VideoController'...
  • Finding Interesting WMI Classes

    WMI is a huge repository. If you want to get to useful information, you will need to specify the name of a valid WMI class. Fortunately, it is easy to search for interesting classes. You can simply use Get-WmiObjectand the -list parameter in conjunction...
  • Rename Drive Label

    WMI can also read any drive label (the name that appears next to a drive inside Explorer), and you can change the drive label, too—provided you have administrator privileges. This code renames drive c:\ to "My Harddrive": $drive = [ wmi...
  • Remove Empty Entries

    One little known fact is that Where-Object is a cool and simple way of removing empty objects. Let's say you want to list all network adapters that have an IP address. You can simply add Where-Object and specify the object property that needs to have...
  • Finding Your Current Domain

    Try this quick and simple way to find out the domain name that you are currently connected: [ ADSI ] "" The domain name is returned if you are currently connected to a domain. Otherwise, you will receive an exception. You can also return arbitrary...
  • Retrieving Clear Text Password

    Get-Credential is a great way of prompting for credentials, but the Password you enter into the dialog will be encrypted. Sometimes, you may need a clear text password. Here is one way to restore the clear text password entered into the dialog: $cred...
  • Use PowerShell Cmdlets!

    Whenever possible, try to avoid raw .NET access if you would like to create more readable code. For example, the following line returns the current date: [ System.DateTime ]:: Now Here is a much better approach: simply use Get-Date: Get-Date Remember...
  • Checking for .NET Framework Version with Powershell

    You can use the -contains operator if you need to check whether a specific version of .NET is present on your system: @(dir $env:windir \ Microsoft.NET \Framework\v * -name ) -contains 'v3.0' ReTweet this Tip!
  • Finding Available .NET Frameworks

    Try this if you would like to get a quick overview of all installed .NET framework versions: dir $env:windir \ Microsoft.NET \Framework\v * -name It will then return a string array with all installed .NET framework versions. ReTweet this Tip!
  • Getting Visual Help for PowerShell Cmdlets

    Here is a new way of getting help for your PowerShell cmdlets: If you are inside the U.S., try this: http://go.microsoft.com/fwlink/?LinkID=190436 If you are outside the U.S., visit this page: http://www.bing.com/visualsearch?mkt=en-us&g=powershell_cmdlets...
  • Secret Timespan Shortcuts

    Usually, to create time spans, you will use New-Timespan. However, you can also use a more developer-centric approach by converting a number to a time span type: [ TimeSpan ]100 This will get you a time span of 100 ticks, which is the smallest unit available...
  • Finding Secret Date-Time Methods

    However, to use developer-centric date-time methods, you will need to know them first. Here is how: Get-Date | Get-Member -memberType * Method This will give you a list of all methods provided by date-time objects. To add six years to today's date...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.