In the previous tip we illustrated how Convert-Umlaut was able to convert special characters in a string. This becomes even more useful if a...
Powershell
Replacing Special Chars like “Umlauts”
PowerShell 2+ Sometimes it becomes necessary to replace special characters like German “Umlauts” in order to normalize user names or...
Using Friendly Robocopy
PowerShell 2+ Robocopy is a tool of choice to copy files, and that does not change with PowerShell. You can, however, use PowerShell to embed...
Beware of Changes to PSModulePath
PowerShell 3+ PowerShell examines the $env:PSModulePath environment variable to find out the locations where it searches for extension modules. A...
The Truth About WinRM
PowerShell 3+ The popular winrm command to manage and configure PowerShell Remoting is really just a batch and a VBS file: PS> Get-Command winrm...
Listening to Music in the Background
PowerShell 3+ In the previous tip we presented to you a “Dancing Rick ASCII”, created by Lee Holmes. Lee uses music stored on his server...
The Most Powerful Reaction in IT
Lately, I’ve been seeing a particular video depicting simple yet amazing chemical reactions making its way through my social media feeds....
Smuggling In PowerShell Code
PowerShell 2 There is a good reason why Invoke-Expression is considered risky. This cmdlet executes whatever string it gets, and attackers can...
Display Windows
PowerShell 3+ It is fairly easy to use WPF (Windows Presentation Foundation) to create and show simple dialog windows in PowerShell. If you’d...
Add a Clock to PowerShell
PowerShell 2+ Here is a fun example that illustrates how to work with timers. It adds a clock to the title bar of the PowerShell console or the...
Changing Page File Location
PowerShell 2+ To move the Windows page file to a new location, you can use WMI: #requires -Version 2 $args = @{ Name = "D:\pagefile.sys" InitialSize...
Encrypting and Decrypting Secret Strings
When there is the need to encrypt sensitive data, scripts always face the challenge to protect the secret key used to decrypt. If the secret is to...
Finding Groups of Logged On User
If you’d like to know the group memberships of the currently logged on user (the one that is running a script), you don’t need to query...
Creating Dynamic Variable Content
PowerShell 2+ In the previous tip we introduced variables with read-only dynamic content that updated each time the variable was read. This required...
Creating Dynamic Variable Content
PowerShell 2+ A little-known fact is that you can add variables to PowerShell that automatically update their content. If you need random numbers,...
Create Simple PowerShell Host
PowerShell 2 or better There are sometimes a lot of good reasons why you’d like to run a script by a different host. powershell.exe might be...
Creating PowerShell Web Server
All Versions Here is an example that implements a simple web server with just a few lines of code. When you run this script, you can enter one of...
Changing Password
All versions Here is a simple way how an existing user can change the password for his account. The user must know his old password and does not...
Opening PowerShell for Folder
Any version If you browsed to a folder using File Explorer, and then would like to open a PowerShell with the current folder set to the browsed...
Getting GIT tips online
Here is an example that illustrates how you access a REST API online. The script retrieves GIT tips. GIT is an open-source control system. Even if...
Creating Shortcut Drives
All PowerShell Versions Simply add a new drive to one of the file locations you often visit: # create folder if it does not exist yet $path =...
Running PowerShell Tasks with Progress Bar
PowerShell 2+ Sometimes it may take some time for a PowerShell command to complete, and while the command is working, the user gets no visual clue....
Colorful Console
PowerShell 5 PowerShell 5.0 on Windows 10 ships with a much-enhanced and colorful PowerShell console. PowerShell 5.0 on other operating systems just...
Finding AD User by SAMAccountName
PowerShell 5 The free Microsoft RSAT tools come with a full-blown ActiveDirectory module, but sometimes simple AD tasks can be mastered with just a...