Here is a one-liner that retrieves your original Windows product key: (Get-WmiObject -Class...
Powershell
Printing PDF Files (Part 2)
In the previous tip we explained how PowerShell can send PDF documents to the default PDF printer. This generic approach is OK for simple scenarios...
Printing PDF Files (Part 1)
To automatically print PDF documents, unfortunately you cannot use Out-Printer. Out-Printer can only send pure text documents to a printer. However,...
Installing Linux on Windows 10
Windows 10 comes with Windows Subsystem for Linux (WSL) feature that you can use to run various Linux distributions. Launch a PowerShell with...
Using Localized User and Group Names
[System.Security.Principal.SecurityIdentifier _i="0" _address="0" theme_builder_area="post_content" /][System.Security.Principal.NTAccount _i="1"...
SID of Current User
Here is a one-liner that returns the SID for the current user and can be used in logon scripts, for example:...
Scanning Ports
Here is a straightforward way to test ports on a local or remote system. You can even specify a timeout (in milliseconds): function Get-PortInfo {...
Resetting Console Colors
It can be easy to mess up console colors in the PowerShell console. A single call with accidental values, or a script that messed with the colors,...
Solving SSL Connection Problems
Sometimes when you try to access web services (or download internet content in general), PowerShell may bail out and complain about not being able...
Deleting the Oldest Log File
Enable Real-Time Streaming with Foreach
Classic foreach loops are the fastest loop available but they come with a severe limitation. Foreach loops do not support streaming. You need to...
Listing Network Drives
There are many ways to create a list of network drives. One involves a COM interface that was used by VBScript as well, and we’ll pick it to...
Sending Emails via Outlook
You can always use Send-MailMessage to send a mail via any SMTP server. If you’d like to use your Outlook client, though, i.e. to keep access...
Title-Casing Strings (Capital Letter Starts Each Word)
Polishing raw text is not always trivial, and when you’d like to make sure names or texts are well-formed, and each word starts with a capital...
Concatenating Text Files
Finding Windows Universal Unique Identifier (UUID)
Every Windows installation has a unique UUID that you can use to distinguish machines. While computer names can change, the UUID won’t: PS>...
Formatting Date and Time (with Culture)
In the previous tip we illustrated how Get-Date can take a format string and convert DateTime values to strings. The string conversion always uses...
Formatting Date and Time
Formatting date and time to your needs is easy with the -Format parameter provided by Get-Date. You can use it either with the current date, or...
Sending PowerShell Results to PDF (Part 4)
In the previous tip we created the function Out-PDFFile which accepts any PowerShell results and turns them into a PDF file – using the built-in...
Sending PowerShell Results to PDF (Part 3)
In the previous tip we explained how you can use PowerShell on Windows 10 and Windows Server 2016 to set up a PDF printer that prints anything to a...
Sending PowerShell Results to PDF (Part 2)
In the previous tip we illustrated how you can use the built-in “Microsoft Print to PDF” printer to send PowerShell output to PDF files. However,...
Sending PowerShell Results to PDF (Part 1)
Windows 10 and Windows Server 2016 finally come with a built-in PDF printer called “Microsoft Print to PDF” that you can use from...
Printing Test Pages on Printers
Windows 10 and Windows Server 2016 come with extensive printer support thanks to the PrintManagement module. If you’d like to print official...
Using FileSystemWatcher Correctly (Part 2)
In the previous tip we introduced the FileSystemWatcher and illustrated how it can miss filesystem changes when your handler code takes too long. To...