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...
ps1
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...
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...
Tag Your Objects with Additional Information
There may be the need to add additional information to command results. Maybe you get data from different machines and want to keep a reference...
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...
Using Aliases to Launch Windows Components
PowerShell is not just an automation language but also an alternate user interface. If you do not like the graphical interface, educate PowerShell...