WMI represents all locally installed printers with its class Win32_Printer, so you can easily look what's installed: PS> Get-WmiObject -Class...
Powershell
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
Using PropertySets
PropertySets are lists of properties, and PowerShell sometimes adds PropertySets to result objects to make picking the right information easier....
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,...
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...
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...
Accessing PowerShell Host Process
With this line, you always get back the process object representing the current PowerShell host: PS>...
Using Specific Error Handlers
If you want error handler to handle specific error types, you can add the error type after the keyword trap or catch. However, this will only work...
Finding Popular Historic First Names
To find popular first names for given decades, check out the function Get-PopularName. It accepts a decade between 1880 and 2000 and then uses the...
Why Using Here-Strings?
To create multi-line text in a script, you can simply enter the multi-line text into your script using quotes: $text = 'First Line Second Line...
Identifying .NET Framework 4.5
PowerShell 3.0 can run both on .NET Framework 4.0 and 4.5. .NET Framework 4.5 adds additional objects and members, so for example this line will...
Testing Numbers and Date
With a bit of creativity (and the help from the -as operator), you can create powerful test functions. These two test for valid numbers and valid...
Get List of Type Accelerators
Ever wondered what the difference between [Int], [Int32], and [System.Int32] is? They all are data types, and the first two are type accelerators,...
Getting Help for Objects – Online
In PowerShell 3.0, you finally can extend object types dynamically without having to write and import ps1xml-files. Here is an especially useful...
Listing Currently Loaded Format Files
The internal PowerShell formatting system (called ETS) relies on XML-based formatting data that comes from .ps1xml files. To see all files currently...