In the previous tip we showed how you can read and change BIOS settings for Lenovo computers. This was the code to disable WakeOnLan, for example:...
Powershell
Managing Lenovo BIOS Settings (Part 3)
In the previous tip we explained how to manage Lenovo BIOS settings from PowerShell. Typically, there are single settings that need to be managed....
Managing Lenovo BIOS Settings (Part 2)
Managing Lenovo BIOS Settings (Part 1)
There is unfortunately no standardized way of managing BIOS settings for computer vendors. Each vendor employs proprietary approaches. For Lenovo...
Exploring PowerShell Modules
Most cmdlets and functions are part of PowerShell modules. If you’d like to explore where exactly these commands come from, here is an easy...
Locking Workstation
If you’d like to lock the current workstation from within PowerShell, you can take advantage of the fact that PowerShell can run executables....
Detecting WinPE
PowerShell can run inside WinPE environments. If you’d like to detect whether your PowerShell script runs inside a WinPE environment, you can...
Extract Specific Files from ZIP Archive
Starting with PowerShell 5, cmdlets like Extract-Archive can extract the content of ZIP files to disk. However, you can always extract only the...
Dumping ZIP Archive Content
PowerShell comes with new cmdlets like Extract-Archive that can extract (all) files from a ZIP file container. However, there is no way to just list...
Validating Variable Content
Beginning in PowerShell 5, you can assign a validator to a variable. The validator can take a regular expression, and once you assign new values to...
Using Profile Scripts
PowerShell by default “forgets” most settings on restart. If you’d like to “keep” settings, you use a profile script....
Optimizing Command Completion
The PowerShell console (powershell.exe, pwsh.exe) offers extensive completion support. When you enter a command and then add a space and a hyphen,...
Reading Registry Remotely (Part 2)
In the previous example we showed the code required to read registry values remotely from another machine using the old-fashioned DCOM protocol. If...
Reading Registry Remotely (Part 1)
If you cannot use PowerShell remoting, and you need to read registry values from another system via DCOM, here is some example code you might want...
Hardening PowerShell Script Block Logging Log
When you enable ScriptBlockLogging, PowerShell logs all PowerShell code that is executed on your machine. Even if it is disabled, any...
Manipulating Registry User Hive
Reading and writing values to the HKEY_LOCAL_USER hive in the registry is easy, because this hive is the same for all users. How would you read or...
Managing Windows Features (Part 2)
In Windows 10, unlike in Windows Server, you cannot use the Get-WindowsFeature and Add-WindowsFeature cmdlets to manage Windows features. However,...
Managing Windows Features (Part 1)
Windows 10 comes with a vast number of features, and only a subset is installed. Manually, you would open Control Panel and look at the Windows...
Running CMD commands in PowerShell
PowerShell by default does not support the native cmd.exe command such as „dir“. Instead, it uses historic aliases called...
Getting Excuses Automatically
Invoke-WebRequest can retrieve HTML info from web pages, and regular expressions can then scrape information from these pages. Here is some code...
Separating Variables in Expandable Strings
When you use double-quoted strings, you can expand variables inside of them like this: PS C:\> "Windir: $env:windir" Windir: C:\Windows...
Finding Windows Build Numbers
When you run winver.exe, you can easily retrieve the full Windows build number. Reading the build number from PowerShell is not as obvious. There is...
Checking for USB Devices
If you’d like to know whether a specific device is attached to your computer, you can use WMI to dump the names of all plug&play devices:...
Using PSGraph
PSGraph is an awesome free PowerShell library that you can use to visualize relationships. Before you can use PSGraph, you need to install its...