PowerShell can access the same logic that is used by the Windows Update Client, and query for missing updates: $UpdateSession = New-Object...
posts-powershell
Who is Starting Hidden Programs?
Ever wondered why your CPU load is so high at times, or why black windows open up for a split second? Then check your event log for program...
Finding Logon Events
Provided you have Administrator privileges, here is a quick and easy way of dumping all login events. This way you can find out who logged in to a...
Resolving URLs
Often, URLs redirect to the final URL, so if you’d like to know where a given URL really points to, use a function like this: function...
Finding Size of Download
When you download files from the internet and use PowerShell, you may want to find out how long the download will take. While you can check the size...
Detecting Key Press
Sometimes it would be nice if a script was able to detect a key press without interfering with the script and its inputs. This way, you could add...
Using FileSystemWatcher Asynchronously
In the previous tip we looked at the FileSystemWatcher object and how it can monitor folders for changes. To not miss any changes, however, an...
Using FileSystemWatcher Synchronously
Here is a chunk of code illustrating how PowerShell can use the FileSystemWatcher to synchronously watch a folder including subfolders for file...
Using Default Credentials for Proxy
When your company uses an authenticated proxy, PowerShell may not always be able to contact the Internet. You may have to instruct the web proxy to...
PowerShell 7
Today we are not talking about code but about PowerShell in general. Microsoft has announced that the next release of PowerShell is called...
RSAT Tools Built-In
The Remote Server Administration Tools (RSAT) used to be an external download that added two important PowerShell modules: ActiveDirectory and...
Searching Files Using Index Search
Windows Indexing indexes most files in your user profile and drives the fast file search in File Explorer. PowerShell can access the same mechanism....
Turn on Streaming for Loops
PowerShell comes with a number of looping constructs. These looping constructs cannot stream, so you cannot pipe the results to other cmdlets and...
Marking Scripts for PowerShell Core or Windows PowerShell
As you probably know, there are two breeds of PowerShell: Windows PowerShell ships with Windows operating systems and is based on the full .NET...
Controlling Audio Volume and Mute Status
To adjust an audio volume and mute/unmute the speaker, PowerShell can use C# code and access API functions like this: Add-Type -TypeDefinition...
Checking for Bad (Insecure) Passwords (Part 2)
In the previous tip we explained how you can use web services to safely test passwords and find out whether they have been compromised before....
Checking for Bad (Insecure) Passwords (Part 1)
Complex passwords are not necessarily safe. For example, “P@ssw0rd” is a very complex password, however extremely insecure. That’s...
Specifying Bit Flags Smart
In the previous tip you have seen how you can enable all SSL security protocols in PowerShell to connect to web services and web sites:...
Using SSL/HTTPS from PowerShell
Depending on your PowerShell and .NET Framework version and update, the default security protocol for secure web connections may still be SSL3. You...
Splitting Texts by Fixed Width
Let’s assume you need to split a text using a fixed width. For example, if you needed the first 5 character of a text, plus the remainder, how...
Get Hashes from Texts
Before the advent of PowerShell 5 (and Get-FileHash), to calculate hashes for strings and files, you’d need to resort to pure .NET methods....
Creating Hashes from Text
A hash is a way to uniquely identify a text without exposing the actual text. Hashes are used to identify texts, find duplicate file content, and...
Pretty Out-GridView Dialog Boxes
When you pipe objects to Out-GridView, the cmdlet shows the default properties, so when you use a grid view window as a selection dialog, you have...
Redirecting PowerShell Output to GridView
When you output data in PowerShell, it gets silently piped to Out-Default and ends up as text in the console. By overriding Out-Default, you can...