database-tools

Launching Applications

When you launch *.exe-applications with arguments, you may get exceptions because PowerShell may misinterpret the arguments. A better way to do this...

Managing File System Tasks

If you need to list all cmdlets that deal with file system-related tasks, try this: Get-Command -Noun item*, path Many of these cmdlets have...

Appending CSV Data

To append a CSV file with new data, first of all make sure the type of data you append is the same type of data already in a file (or else column...

Create CSV without Header

ConvertTo-CSV can create comma separated values (CSV) on the fly but it always adds a new header. To create CSV data without columns, take a look at...

Checking Array Content With Wildcards

In a previous tip we illustrated how -like can work on array. To iterate on that, check out how -like (in contrast to -contains) allows the use of...

Assigning Two Unique Random Numbers

If you need to get two random numbers from a given numeric range, and you want to make sure they cannot be the same, simply tell Get-Random to pick...

Eliminating Empty Text

If you wanted to exclude results with empty (text) columns, you can filter based on $null values. This will get you all processes with a valid...

Adding Personal Drives

In a previous tip we showed you how you can add new drives to easily access your desktop, your cookies or media like music and video. However, when...

Combining Network Adapter Information

In a previous tip you learned that WMI network adapter information is separated into two classes. Win32_NetworkAdapter represents the hardware, and...

Getting Network Adapter Settings

To view the configuration details of a network adapter, you can specify the network adapter connection ID as it appears in your control panel. ...

Enumerating Network Cards

In a previous tip you learned how to use a shortcut to quickly open the dialog with your network adapters. Today, you get a piece of code to access...

Shortcut to Network Cards

To quickly access the settings for your network cards, use this line from within PowerShell: explorer.exe...

Find Local Group Members

If you'd like to list all members of local groups, encapsulate net.exe and make it a PowerShell function: function Get-LocalGroupMember{ param(...

Find Local Groups

On Windows 7, net.exe can list all local groups. To use this information with PowerShell, try this simple wrapper: function Get-LocalGroup { net...

Find Local Users

On Windows 7, the easiest way to find local user accounts is to use net.exe. Here is a simple PowerShell wrapper called Get-LocalUser: function...

Escape Regular Expressions

PowerShell supports regular expressions in a lot of areas which is why the following code fails: 'c:\test\subfolder\file' -split '\'...

Monitor Open Files

In a previous tip we introduced the command openfiles which lists and disconnects files that were opened remotely on your machine. Openfiles can...

Finding Open Files

If you'd like to see which files are opened by network users on your machine, there is an internal command for it. All you need are local admin...

Removing File Extensions (Safe)

In a previous tip we showed that Trim() is an unsafe way for removing file extensions. A safe way uses .NET methods:...

Removing File Extensions (Unsafe)

Some users use Trim() to remove file extensions like this: 'c:\test\file.txt'.Trim('.txt') c:\test\file This seems to work great,...

Finding Useful WMI Classes

To find the most useful WMI classes you can use Get-WmiObject, and let PowerShell provide you with a hand-picked list: Select-XML...

Finding Type Definitions

PowerShell enhances many .NET types and adds additional information. These changes are defined in xml files. To list all .NET types that get...

Analyze Cmdlet Results

There are two great ways to analyze the results a cmdlet returns: you can send the results to Get-Member to get a formal analysis, telling you the...

Listing Process Owners

In a previous tip, you learned that there is a hidden host process named wsmprovhost.exe whenever someone else visits your computer using PowerShell...

Detecting Remote Visitors

Whenever someone connects to your computer using PowerShell remoting, there is a host process called wsmprovhost.exe. You can only see processes...

Echoing The Error Channel

To control which output from a batch file is considered "a result" and which output should rather always be visible to the user, you can...

Make Sure Folder Exists

To ensure that a given folder exists, you can stick to trial-and-error, and hide error messages: New-Item c:\somefolder\anotherfolder\yetanother...