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

Archives

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
  • Installing Local Printer

    WMI represents all locally installed printers with its class Win32_Printer, so you can easily look what's installed: PS > Get-WmiObject -Class Win32_Printer | Select-Object -Property * To add a new local printer, just add a new instance of Win32_Printer...
  • Parsing Custom Date and Time Formats

    Sometimes, date and time information is not formatted according to the standards PowerShell understands by default. When this happens, you can provide a hint and tell PowerShell how to correctly interpret date and time. In this example, $information contains...
  • Discovering Network Access

    PowerShell can access low-level COM interfaces to find out system information such as network access. This code returns a list of all active network adapters and works with Vista/Server 2008 and above: $cat = ' Public ' , ' Private ' ...
  • Finding Constructors (and submitting Credentials unattended)

    When you need to log on with alternate credentials, cmdlets often pop up a login dialog, like here: $cred = Get-Credential If you wanted to run a script unattended, you would have to generate the credential object manually instead. To generate a new object...
  • Checking Network Adapter Speed

    Sometimes, just one line of PowerShell code gets you all the information you may have needed. There is a .NET type called NetworkInterface, for example, that lists all of your network adapters, their speed and status: PS > [ System.Net.NetworkInformation...
  • Finding WMI Class Static Methods

    In a previous tip, we illustrated how to use Invoke-WmiMethod to create a network share locally and remotely. Today, you dive a bit deeper and find out which WMI classes actually provide methods, and what their arguments and argument orders are. Note...
  • Converting Date from French to Taiwanese

    Date and Time formats are highly culture-specific, so often you need to convert date and time from one cultural format to another. That's pretty straight-forward. All you need to know are the culture IDs to convert from and convert to. This line will...
  • Create File Shares Remotely

    To create a new file share remotely, you could use the WMI class Win32_Share and its Create() method. Invoke-WmiMethod helps you run WMI methods locally and remotely. To create a new share locally or remotely, try this: $Path = ' C:\ ' $Name ...
  • Displaying WMI Inheritance

    In PowerShell 3.0, the (hidden) object property PSTypeNames shows you the complete inheritance tree for WMI objects: PS > $os = Get-WmiObject -Class Win32_OperatingSystem PS > $os . pstypenames System.Management.ManagementObject # root \ cimv2 ...
  • Auto-Discovering Online Help for WMI

    Get-WmiObject is a great and simple cmdlet to retrieve WMI information, and the parameter -List returns all available WMI class names that you can specify: # search for WMI class name: PS > Get-WmiObject -Class * Share * -List # retrieve all instances...
  • Using MemberSets

    In a previous tip you learned how PropertySets can create groups of properties for easier access. Yet another (hidden) feature of PowerShell objects is MemberSets. Objects can contain a MemberSet called PSStandardMembers which normally is hidden (along...
  • Using PropertySets

    PropertySets are lists of properties, and PowerShell sometimes adds PropertySets to result objects to make picking the right information easier. Get-Process for example returns process objects, and these contain two PropertySets: PS > Get-Process ...
  • Getting Weather Forecast from an Airfield near You

    PowerShell can access web services and automatically retrieve information such as weather forecasts. New-WebServiceProxy does all the work for you, and you only need to submit the web service URL. Note however that New-WebServiceProxy requires direct...
  • Checking System Uptime

    In a previous tip we explained how you read date and time information from WMI and convert it into a regular date and time information. With this technique, you can then manipulate and calculate with the regular date and time functions. So, this piece...
  • Converting Date to WMI Date

    WMI (Windows Management Instrumentation, Get-WmiObject ) uses a specific (DTMF) format for date and time. You can easily convert regular date and time information into this format: PS > $date = Get-Date PS > $wmidate = [ System.Management.ManagementDateTimeConverter...
« First ... < Previous 58 59 60 61 62 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.