database-tools

Finding Next Sunday

If you'd like to find out how long it is until next Sunday (or how many days have passed since last Sunday), simply use the property DayOfWeek. It...

Dumping Scheduled Tasks

There is an underestimated option to make schtasks.exe dump scheduled tasks as CSV data. PowerShell can grab the CSV data and turn it into objects,...

Get Quotes From the Webservices

There are plenty of free webservices around, and provided you have direct Internet access (no proxy), you can use New-WebServiceProxy to access...

Using Safe Cmdlets Only

Let's assume you want to set up a restricted PowerShell v3 console that just provides access to Microsoft cmdlets with the verb Get. One way to...

Finding Published Printers

Finding printers that have been published in your Active Directory becomes trivial with Windows 8 or Server 2012. PS> Get-Printer -ComputerName...

Get CPU Load

To get the average total CPU load for your local system or a remote system, use Get-Counter. The example below returns the average total CPU load...

Calling WMI Methods with CIM Cmdlets

It can be very useful to call WMI methods, for example to create new shares, but in PowerShell v2 you had to know the names and exact order of...

Listing Power Plans

There is a somewhat hidden WMI namespace that holds WMI classes you can use to manage power plans. The code below lists all power plans on your...

Mixing DCOM and WSMan in WMI Queries

Using the new CIM cmdlets in PowerShell v3, you can run remote WMI queries against multiple computers using multiple remoting protocols. The sample...

New Operator -In

In PowerShell v3, you can use a new simplified syntax for Where-Object. Both lines below list all files in your Windows folder that are larger than...

New WMI Cmdlets with DateTime Support

In PowerShell v3, to work with WMI you can still use the old WMI cmdlets like Get-WmiObject. There is a new set of CIM cmdlets, though, that pretty...

Finding Keyboard and Mouse

You can use WMI to quickly find all details about your mouse and keyboard: PS> Get-WmiObject win32_PointingDevice | Where-Object { $_.Description...

Finding Built-In Variables Part 2

In a previous tip we featured a piece of undocumented code that works in PowerShell v3 to list all built-in variables. Here is another approach that...

Adjust Text to Specific Length

If you must make sure that a text has a fixed length and is neither shorter nor longer, here is the code to pad and cut the text to the desired...

Displaying MsgBox TopMost

In a previous tip you learned how to load additional .NET assemblies. This enables you to display dialog boxes like a MsgBox, pretty much like in...

Loading Additional Assemblies

When you want to load additional .NET assemblies to extend the types of object you can use, there are two ways of loading them: the direct .NET...

Using Open File Dialogs

To spice up your scripts, PowerShell can use the system open file dialog, so users could easily select files to open or to parse. Here's the...