T O P

Powershell One-liner to Check Log Files

Troubleshooting Windows Update with a Little PowerShell Magic

Let’s suppose you’ve just joined a computer to a WSUS server, but Windows Update has decided it doesn’t feel like downloading patches today.

Naturally, your first instinct is to check the logs. But who wants to spend their afternoon digging through files looking for an error?

Fortunately, PowerShell can do the dirty work for us.

Back in the day, Windows Update maintained a nice, readable log file. Finding warnings was as simple as:

Get-ChildItem C:\Windows -Filter '*update*.log' -File -Recurse -ErrorAction SilentlyContinue |
    Select-String 'warning'

One line, and PowerShell searches for matching log files, reads their contents, and displays anything containing the word “warning.”

In my case, the result was rather revealing:

WARNING: Failed to find updates with error code 800B0001
WARNING: Digital Signatures are not trusted: Error 0x800b0001
WARNING: SelfUpdate check failed, error = 0x800B0001
WARNING: Skipping scan, self-update check returned 0x800B0001

Aha! There’s our culprit: 0x800B0001, pointing toward a digital signature verification issue.

But wait, it’s not 2013 anymore!

Modern Windows versions (Windows 10, Windows 11, and newer Windows Server releases) no longer maintain the same continuously updated text log. Instead, they use Event Tracing for Windows (ETW).

Not quite as convenient, but PowerShell still has our backs.

First, generate a readable log:

Get-WindowsUpdateLog -LogPath "$env:TEMP\WindowsUpdate.log"

Then search it:

Select-String "$env:TEMP\WindowsUpdate.log" -Pattern 'warning','error','failed'

Or, if you’re feeling particularly efficient, skip the log file altogether and query the Windows Update event log:

Get-WinEvent -FilterHashtable @{
    LogName = 'Microsoft-Windows-WindowsUpdateClient/Operational'
    Level = 2,3
} -MaxEvents 20 | Select-Object TimeCreated, Message

That retrieves up to 20 recent error and warning events, without opening Event Viewer.

And yes, these approaches work with Windows PowerShell 5.1 and modern PowerShell 7 versions.

One last trick

For traditional text logs that are actively being written, you can still watch for errors in real time:

Get-Content C:\Logs\Application.log -Tail 20 -Wait |
    Select-String 'warning','error'

Just remember that this trick doesn’t work directly with modern Windows Update’s binary ETW traces.

The moral of the story?

Windows Update may have changed how it keeps its secrets, but PowerShell is still remarkably good at getting them out.

Happy troubleshooting!

Finding Windows Services That Are Stopped That Should Be Started With Powershell

This was a scriptlet that got heavy use on servers and even in our RMM. It can report back services on Windows servers and desktops are are in the Stopped state that are set to Auto or Enabled.

GWMI is short for Get-WmiObject

GWMI win32_service -Filter "startmode = 'auto' AND state != 'running'"  | select DisplayName, Name, StartMode, State, ExitCode | ft -auto

Issues Upgrading Windows 10 Pro to Enterprise with AzureAD and E5 Licenses

A client of ours wanted to upgrade their Windows 10 Professional licenses to Windows 10 Enterprise by way of E5 licensing in Office365 / Azure Active Directory.

Most computers worked fine, but a few just didn’t work and upgrade as they should have. There isn’t a lot of documentation on this, so I thought I’d put out there what worked for us and what we found. I ended up opening a ticket with Microsoft Escalated Support and worked with a rep over a few weeks.

First and foremost, make sure in Office365 that the E5 license has the option checked off for Windows 10 Enterprise.

First Troubleshooting Recommendation: dsregcmd

Run dsregcmd /status on the affected machine as the logged in user (and not a System or admin account).

If WamDefaultSet : ERROR and / or AzureAdPrt : NO are found, these would indicate an issue on Azure’s end. You want to see both answered with YES. These fields indicate whether the user has successfully authenticated to Azure AD when signing in to the device.

If the values are NO, it could be due to:

  • Bad storage key in the TPM associated with the device upon registration (check the KeySignTest while running elevated).
  • Alternate Login ID
  • HTTP Proxy not found

Reset Your Password in Windows 10 Bash / Ubuntu

If you forget your root password for Bash on Windows, you can do the following to reset your password:

First, run: lxrun /setdefaultuser root . This will open a new Bash window as root.

From there, run: passwd your_username and then enter your new root password

Then change the default user for Bash back to your user: lxrun /setdefaultuser your_username

 

That’s it! Enjoy Bash on Windows 10.

Windows 10 Will Let You Choose Which Drive to Store Default Folders On

With the growing popularity of SSDs, a lot of users have been using SSDs for boot drives and HDDs for storage. In Windows 10, there is an exciting new feature which will automatically and seamlessly let you choose what folders and files get put on a secondary HDD. This includes “My Documents”, “My Pictures”, and even applications.

The setting is under Settings > System > Storage and can be seen below:

Windows10Choice