database-tools

Finding USB Stick Information

Did you know that Windows logs any USB stick type you ever used? To get that information from the Registry, simply use this function: function...

Finding Expired Certificates

PowerShell grants access to your certificate stores by using the cert: drive. You can use this drive to find certificates based on given criteria....

Submitting Arguments to EXE Files

Running applications such as robocopy.exe from PowerShell sometimes is not trivial. How do you submit arguments to the EXE so that PowerShell...

Applying NTFS Access Rules

There are many ways to add or change NTFS permissions. One is to reuse existing tools such as icacls.exe. This function will create new folders that...

Profiling Systems

If you just want to profile a local or remote system and get back the most commonly used pieces of information, then do not waste time for your own...

Get-WirelessAdapter

In the previous tip, we illustrated how you can use Registry information to find wireless network adapters. Here is now a function...

Finding Wireless Network Adapters

There are many ways of finding network adapters, but apparently none to identify active wireless adapters. All information about your network...

Drive Data in GB and Percent

When a cmdlet returns raw data, you may want to convert the data into a better format. For example, WMI can report the free space of a drive but...

Finding Errors since Yesterday

Relative dates are important to get data within a special time frame, avoiding hard-coded dates and times. This script will get all error and...

Exporting Data to Excel

You can easily convert object results to CSV files in PowerShell. This generates a CSV report of current processes: To open the CSV file in...

Finding Events around A Date

Often, you might want to browse all system events around a given date. Let's say a machine crashed at 08:47, and you'd like to see all...

Auto-Connecting with Public Hotspot

Many mobile phone service providers offer public hotspots at airports and public places. To connect, you typically need to browse to a logon page,...

Padding Strings Left and Right

If you must make sure that a given string has a uniform width, then you can use .NET methods to pad the string appropriately: $mytext =...

Formatting Numbers Easily

Often, users need to format numbers and limit the number of digits, or add leading zeros. There is one simple and uniform strategy for this: the...

Eliminating Duplicates

Sort-Object has an awesome feature: with the parameter -Unique, you can remove duplicates: This can be applied to object results, as well. Check out...

Beware Of Hidden Password Requests

You can run PowerShell code in any host, and Windows ships with powershell.exe and powershell_ise.exe. Many prefer the graphical ISE editor over the...

Save Time With Select-Object -First!

Select-Object has a parameter called -First that accepts a number. It will then return only the first x elements. Sounds simple, and it is. This...

Expanding Variables in Strings

To insert a variable into a string, you probably know that you can use double quotes like this: $domain = $env:USERDOMAIN $username = $env:USERNAME...

Filtering Text-Based Command Output

Comparison operators act like filters when applied to arrays. So any console command that outputs multiple text lines can be used with comparison...

Keeping a Handle to a Process

When you launch an EXE file, PowerShell will happily start it, then continue and not care about it anymore: If you'd like to keep a handle to...

Use $PSScriptRoot to Load Resources

Beginning in PowerShell 3.0, there is a new automatic variable available called $PSScriptRoot. This variable previously was only available within...

Signing VBScript Files with PowerShell

You probably know that Set-AuthenticodeSignature can be used to digitally sign PowerShell scripts. But did you know that this cmdlet can sign...