By default, Get-ADUser (provided by ActiveDirectory module which is part of the free Microsoft RSAT tools) retrieves only a few default properties....
Powershell
Careful with Get-Credential and SecureStrings
Sometimes, scripts interactively ask for credentials, or passwords. Always be aware that the script author can get to the plain text of all entered...
Managing Credentials (Part 5)
When PowerShell auto-encrypts a secure string, it uses your identity as secret. Only you can decrypt the secure string. What if you want to encrypt...
Managing Credentials (Part 4)
In the previous script we showed how you can save a credential object in encrypted form to disk. A similar approach just saves the secret password...
Managing Credentials (Part 3)
For unattended scripts, it is generally unsafe and not recommended to hard-code secret passwords into a script. As an alternative, you could ask for...
Managing Credentials (Part 2)
For scripts running unattended, you can create login credentials from code. This requires the secret password to be saved as clear text in a script...
How to Run PowerShell Scripts with Uptime Infrastructure Monitor
Introduction Microsoft PowerShell is an automation platform and scripting language for Windows and Windows Server that allows you to simplify the...
Managing Credentials (Part 1)
Let’s assume you need to run a script every day that requires credentials. A safe way of storing credentials is to save them encrypted in a...
Parsing Raw Text (Part 3)
In the previous tip we illustrated how you can use Select-String to find lines in raw text containing a specific word. It took some effort to...
Parsing Raw Text (Part 2)
In the previous tip we explained how you can use Select-String and a regular expression to extract valuable information from raw text results: PS...
Parsing Raw Text (Part 1)
Sometimes, you may want to extract valuable information from pure text results. One easy way is the use of Select-String. This example extracts only...
Adjusting Simple UIs
In the previous tip you learned how you can use Show-Command to create simple UIs for text-based commands: #requires -Version 3.0 function...
Creating Simple UIs
Function and cmdlet parameters basically are the technique how PowerShell creates „user interfaces“. These text-based interfaces can...
Extending Robocopy
PowerShell can add value to existing commands such as robocopy. Take a look at the below function--it uses robocopy to copy files, and adds the...
Copy Color-Coded Code
When you select code in the PowerShell ISE and copy it to the clipboard, it is copied in RTF format and preserves all color coding and font...
Creating WinForms GUIs in PowerShell
While it is recommended to use the modern WPF technology to create PowerShell user interfaces, you might still want to occasionally use the older...
Using “Exit” to Communicate with Linux
When a PowerShell script ends, you can run the command “Exit” and submit a numeric value. This has been good practice in the Windows...
Capturing Linux Output
If you run PowerShell on Linux, you can combine Linux and PowerShell commands. To take the output of a Linux command and assign it to a PowerShell...
Test for File or Folder
Test-Path can check whether a file or folder exists. If you add -PathType and specify Leaf (for files) or Container (for folders), the result can be...
System Memory, Units, and Rounding
Sometimes, you’d like to use different units of measurements. The total system memory is reported in bytes, for example. Here are some...
Creating Time Spans
You can use New-TimeSpan to define “amounts” of time, and then add or subtract them from dates. Here is an example: $1Day = New-TimeSpan...
Waiting for Processes to Exit
Sometimes, a PowerShell script needs to wait for external processes to finish. Here is what some users do: $processNameToWaitForExit =...
Using PowerShell Remoting with PIN-enabled Accounts
If you have set up a PIN to log into your computer, PowerShell remoting against your own machine may fail with a weird error message: PS C:\>...
Separating Results by Property Value
If you use PowerShell remoting to receive information from remote machines, you can use fan-out simply by specifying more than one computer name....