Powershell

Reading 4K-Hash

Windows operating systems can be uniquely identified by a so-called 4K-Hash: this is a special hash string that is 4000 bytes in size. You can use...

Sophisticated Battery Report

If your laptop battery is going low too soon, or you’d like to investigate related issues, there is a simple way to generate an extensive...

Adding PowerShell commands for Azure

To manage and automate your assets in the Azure cloud, you can easily install a free PowerShell module which comes with a wealth of new PowerShell...

Showing Wi-Fi SSIDs

In the previous tip we illustrated how you can dump all Wi-Fi profile names using netsh.exe. Typically, profile names and SSIDs are identical....

Dumping Wi-Fi Passwords

In the previous tip we used netsh.exe to dump Wi-Fi profiles. Let’s take it a step further and expose the cached passwords: # get cleartext...

Showing Wi-Fi Profiles

PowerShell is not limited to cmdlets and can run executables. For example, there is no built-in cmdlet to list the existing Wi-Fi profiles, but...

Redirecting Streams

PowerShell writes output information to six different streams, and only the output stream is assigned to variables: function Invoke-Test {...

Silencing Write-Host Statements

Write-Host is an extremely useful cmdlet to output information to a user because this output cannot be discarded: function Invoke-Test {...

Discarding Streams

PowerShell outputs information via different streams. Warnings are written to a different stream than output, and errors again go to a different...

Discarding (Any) Output

There are (a few) commands in PowerShell that output information to the console no matter what you do. Neither redirection of streams nor assigning...

Identifying Operating System Details

WMI returns a cryptic number when you ask for operating system details: PS> Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object...

Changing Operating System Description

Each Windows operating system has a description, and you can view (and change) this description with the following command: PS> control sysdm.cpl...

Removing Empty Properties

WMI and Get-CimInstance can provide you with a lot of useful information but the returned objects often contain a number of empty properties: PS>...

Using Assertions

Often, your code needs to assert certain prerequisites. For example, you may want to ensure that a given folder exists, and use code like this: #...

Wake On LAN

There is no need for external “Wake On LAN” tools. If you want to wake up a network machine, simply tell PowerShell the MAC address of...

Converting Hex Numbers

PowerShell can interactively convert hexadecimal numbers when you prefix “0x”: PS> 0xAB0f 43791 If the hex number is stored in a...

Auto-Learning Argument Completion

Argument completion is awesome for a user because valid arguments are always suggested. Many built-in PowerShell commands come with argument...

Adding Argument Completion (Part 2)

In the previous tip we talked about the new [ArgumentCompletions()] attribute that was added to PowerShell 7, and how you can use it to add...

Adding Argument Completion (Part 1)

Adding argument completion to your PowerShell function parameters can improve the usability of your functions tremendously. A common approach is...

Decoding Windows Product Key (Part 2)

In the previous tip we explained how you can ask WMI for a partial Windows product key. If you have lost your original product key, here is a way to...

Decoding Windows Product Key (Part 1)

There are a lot of script examples out there and even key recovery tools that promise to return the full product key, but in many cases, the...

Reading Operating System Details

PowerShell can easily retrieve important operating system details such as the build number and version by reading the appropriate registry values: #...

Prompting for Credentials in Console

When you run Get-Credential or are otherwise prompted for a username and password, Windows PowerShell (powershell.exe) always opens a separate...

1 11 12 13 14 15 104