With Regular Expressions, you can easily extract matching text. Have a look: $text = 'The problem was discussed in KB552356. Mail feedback to...
database-tools
Use Select-String with Context
Select-String can find lines with a specific keyword. It can also include context-relevant lines before and after that line. This will filter the...
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...
When to use Select-Object’s -ExpandProperty
Use Select-Object to determine which information in a result you are interested in. Here are three easy rules for its parameters: Use -Property *...
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 '\'...
What are Hardware Requirements for Monyog?
We are often asked by users deploying MONyog what hardware system they should plan for it. Typically they have been evaluating and testing with a...
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,...