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...
database-tools
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...
Is Using RECONFIGURE WITH OVERRIDE dangerous?
One of my pet peeves is the use of RECONFIGURE WITH OVERRIDE in scripts to change server options. Am I being unreasonable or is this justified? All...
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...
Renaming Object Properties in Powershell
Let's say you want to output just your top-level processes like this: PS> Get-Process | Where-Object { $_.MainWindowTitle } | Select-Object...
Examine "Extended" Object Members
PowerShell is based on .NET objects but often refines them by adding more. If you'd like to see just what PowerShell has added, use Get-Member...
Writing Back WMI Property Changes
Only a few properties in WMI objects are actually writeable although Get-Member insists they are all "Get/Set": PS> Get-WmiObject...
Increase SQL Server Performance Using Multiple Files
By default, SQL Server databases are comprised of two files: the primary data file (or .mdf) and the log file (or .ldf). It is, however, possible to...
Errors Travel in the Opposite Direction
Here's a piece of code for you to wrap your head around: 1..10 | ForEach-Object { trap { Write-Host "Phew: $_"
Creating Dynamic Breakpoints
The PowerShell 3.0 ISE editor has a simple debugger built-in that supports line breakpoints. Simply press F9 to set a breakpoint (which only works...
Creating "Mini-Modules"
Did you know that every PowerShell function can be turned into a script module with just one line of code? To test drive this, open the ISE editor...
Ripping All Links from a Website
PowerShell 3.0 comes with a great new cmdlet: Invoke-WebRequest! You can use it for a zillion things, but it can also simply retrieve the content of...