If you wanted to store sensitive data in a way that only you could retrieve it, you can use a funny approach: convert some plain text into a secure...
powertips
Using Encrypting File System (EFS) to Protect Passwords
If you absolutely need to hardcode passwords and other secrets into your scripts (which you should avoid for obvious reasons), then you might still...
Testing UNC Paths
Test-Path can test whether or not a given file or folder exists. This works fine for paths that use a drive letter, but can fail with pure UNC...
Enabling PowerShell Remoting
If you'd like to use PowerShell Remoting to execute commands and scripts on another machine, then you need to enable Remoting on the target side...
Enabling Classic Remoting
Many cmdlets have built-in remoting capabilities, for example Get-Service and Get-Process both have the parameter -ComputerName, and so does...
Exporting and Importing Credentials in PowerShell
Credential objects contain a username and a password. You can create them using Get-Credential, and then supply this object to any cmdlet that has...
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 Time Servers (And Reading All RegKey Values)
Maybe you'd like to get a list of timeservers registered in the Registry database. Then you probably run code like this: Get-ItemProperty -Path...
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...
Running Commands Elevated in PowerShell
Sometimes, a script may need to run a command that needs elevation (Administrator privileges). Instead of requiring the script to run with full...
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 Hard Drives Running Low on Storage
WMI can retrieve information about drives easily. This will get you the drive information for your local machine (use -ComputerName to access a...
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...