PowerShell contains some binary operators that are not so commonly used, for example bitwise shifting. The -shl operator shifts bits to the left:...
ps1
Converting Binary String to Integer
Here is how you convert a binary text string into the corresponding integer value: $binary = "110110110" $int =...
Using Clipboard to Transfer Data and Results
Finally in PowerShell 5, there is support for sending results to the clipboard, and receiving results from the clipboard: PS> Get-Command -Noun...
Installing MSI on Remote System
How .Replace() and -replace differ
There are two ways of replacing text in a string: the Replace() method, and the –replace operator. They work fundamentally different....
HTML Encoding Advanced
The static .NET method HtmlEncode does a good job encoding the usual character codes but fails with many special characters. To encode all...
HTML Encoding
There is a static .NET method that you can use to HTML-encode text, for example if you want the text to display correctly in HTML output: PS>...
Bulk Printing Word Documents
This line finds all Word documents in your profile: Get-ChildItem -Path $home -Filter *.doc* -Recurse If you’d like, you can easily print them all....
Downloading Videos From German Media Databases
In Germany, there are publicly available media databases with most of the TV content broadcasted by public stations. It just takes very little...
Translating Error Records
Whenever PowerShell records an error, it wraps it in an Error Record object. Here is a function that takes such an error record and extracts the...
Enable AD Users with Out-GridView
Sometimes it requires just a couple of lines of code in PowerShell to produce highly useful helpdesk tools. Here is one that displays all currently...
Turning AD User into a Hash Table
Sometimes it could be useful to load all attributes from a given AD user into a hash table. This way, you could edit them, and then use Set-ADUser...
Cloning Folder Structures (with NTFS Permissions) – Part 2
In the previous tip we illustrated how Get-FolderStructureWithPermission can document and create a list of all nested folders in a structure, along...
Cloning Folder Structures (with NTFS Permissions) – Part 1
Sometimes you need to re-create a nested folder structure, and may also want to clone the NTFS permissions. Today we are tackling the first step:...
Evaluating Exit Codes (aka Error Level – Part 3)
In part 3 of our mini-series about running console applications in PowerShell, here is a goodie: how can you run a console application separately...
Evaluating Exit Codes (aka Error Level – Part 2)
When you directly launch a console-based application, PowerShell returns its exit code (aka Error Level) in the automatic variable $LASTEXITCODE....
Evaluating Exit Codes (aka Error Level – Part 1)
When running a console-based application, it typically returns a numeric exit code. The meaning of this exit code is up to the console-based...
Ejecting CD Drive
Here is a fun little function that uses WMI to eject your CD drive. It does so by first asking WMI for all CD drives. It then uses the explorer...
Identifying CSV Delimiter
[a-z0-9 0="äöüß"()" _i="0" _address="0" theme_builder_area="post_content" /]
Identifying Duplicate CSV Headers (Part 2)
[Import-Csv _i="0" _address="0" theme_builder_area="post_content" /]
Identifying Duplicate CSV Headers (Part 1)
Serializing Date and Time in a Culture-Invariant Way
When you save date and time to text, for example when exporting to CSV, or when creating text reports, DateTime objects are converted to the date...
Converting Ticks to Date and Time (Part 2)
In the previous tip we explained how you convert date and time displayed as ticks to a true DateTime format. However, there are two different time...
Converting Ticks to Date and Time (Part 1)
Occasionally, you may run into strange date and time representations: they might be represented as a 64-bit integer like this: 636264671350358729....