PowerShell is just a scripting engine. All of its cmdlets come from external modules, and the environment variable $env:PSModulePath returns the...
ps1
Testing Well Formed URLs
PowerShell is API-based so often, you don’t need to dive into regular expressions and text patterns. Instead, there is a multitude of...
Running on Windows PowerShell – Or Not? (Part 2)
In the previous tip we featured a backward-compatible one-liner that can tell whether your script is running in the classic Windows PowerShell...
Running on Windows PowerShell – Or Not? (Part 1)
PowerShell can run on various platforms these days, and in the previous tip we explained how you find out the operating system that your scripts are...
Determining Your Platform
PowerShell today is cross-platform so even though you may still use Windows PowerShell on Windows servers, your scripts may well end up running on...
Escaping Individual Characters
In previous tips we explained how you can escape entire string sequences. If you just need to escape an individual character, use HexEscape() like...
Safely Escaping Data Strings
Typically you use methods like EscapeUriString() to safely escape string data that you want to append to URLs (as pointed out in our previous tip)....
Escaping Strings in URLs
When adding string information to URLs, i.e. to construct requests for calling REST web services, it is important to escape special characters. The...
Dynamically Composed IntelliSense
When designing PowerShell functions, you can improve usability tremendously by adding clever argument completion IntelliSense. To compose argument...
Auto-Logon After Windows-Reboot
If your automation script needs to restart the machine, and you want to auto-logon after the reboot, here is a quick script that saves the logon...
Automating Lenovo Driver Downloads (Part 2)
In the previous example we illustrated how you can scrape Lenovo driver information from the web. In this example, some of the information returned...
Automating Lenovo Driver Downloads (Part 1)
Many hardware vendors offer web-based self-service portals. Here is an example taken from Lenovo that returns detailed information about driver and...
Out-GridView with Custom Columns
Out-GridView can be a universal dialog when you use the -OutputMode or -PassThru parameters. When you do, a grid view window displays additional...
Accessing Lenovo BIOS Downloads (Part 2)
In this mini-series we illustrate how you can automate the process of looking up vendor information. While this mini-series focuses on Lenovo and...
Accessing Lenovo BIOS Downloads (Part 1)
In this mini-series we illustrate how you can automate the process of looking up vendor information. While this mini-series focuses on Lenovo and...
Creating New Objects (Part 4)
While most PowerShell users still use hash tables to create new objects, our previous tips have shown that classes aren’t hard to use and...
Creating New Objects (Part 3)
While most PowerShell users still use hash tables to create new objects, in the previous tip we introduced classes and their superior type safety....
Creating New Objects (Part 2)
Most PowerShell users use hash tables to create objects, and so did we in the previous tip: $o = [PSCustomObject]@{ Name = "Tobias" Id =...
Creating New Objects (Part 1)
In PowerShell, you can use hash tables to create ad-hoc objects: $o = [PSCustomObject]@{ Name = "Tobias" Id = 19 Submission = Get-Date...
Repair PowerShellGet and Publish-Module
Publish-Module is a cmdlet used to publish (upload) a module to a NuGet repository. Occasionally, this cmdlet raises strange exceptions. The reason...
Check for Pending Reboot
The code below tests whether a reboot is pending: $rebootRequired = Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based...
Disabling Webcams
Looking for privacy? Here is a short script that looks for enabled cameras on your system and offers you to disable any camera you don’t want...
Using SOAP Webservices
Even though SOAP hasn’t been used widely for public webservices (in favor of more simplistic REST services), internally many companies do use...
COVID Webservice with PowerShell
Do you want to stay up-to-date with Covid pandemic parameters? Try this simply webservice: $result = Invoke-RestMethod -Uri...