Start-WUScan on remote PC

239 views
Skip to first unread message

Gordon Pegue

unread,
Mar 14, 2022, 4:59:35 PM3/14/22
to ntpowe...@googlegroups.com

Thought this would work but I’m missing something:

 

PS C:\WINDOWS\system32> $ComputerName = 'PDITSLTDL01A'

 

PS C:\WINDOWS\system32> $session = New-PSSession $ComputerName -Credential $cred

 

PS C:\WINDOWS\system32> Invoke-Command -Session $session -ScriptBlock { Start-WUScan -SearchCriteria "Type='Software' AND IsInstalled=0" }

Provider load failure

    + CategoryInfo          : NotSpecified: (root/Microsoft/...FT_WUOperations:String) [Invoke-CimMethod], CimException

    + FullyQualifiedErrorId : HRESULT 0x80041013,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand

    + PSComputerName        : PDITSLTDL01A

Scan hit error: .ReturnValue

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException

    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Start-WUScan

    + PSComputerName        : PDITSLTDL01A

 

I know the remote session is instantiated properly because another part of the larger script that uses an Invoke-Command line to write to the remote registry works just fine.

 

It looks – based on google hits from my searches – like the Start-WUScan module was deprecated/removed starting with version 2004.

 

So my questions are:

 

Is there an alternative I can use with Invoke-Command that doesn’t require me to physically touch all the remote PC’s and install the PSWindowsUpdate module in PS?

Or is there a way to install that module via Invoke-Command?

 

What am I trying to do:

Set the TargetReleaseVersionInfo to 20H2 on machines that are on version 2004 (this part works) and then trigger a scan for updates in order to pull down the 20H2 enablement package.

 

I just found this:

https://katystech.blog/powershell/ps-remotely-updating-devices

And it looks like it might provide all my answers.

 

Someone want to concur or offer an alternative while I digest that article?

 

TIA

Gordon

Michael B. Smith

unread,
Mar 14, 2022, 5:03:52 PM3/14/22
to ntpowe...@googlegroups.com

WU PS module was not just deprecated, but deimplemented. Pissed me off big time. Broke life cycle management promises.

 

There are replacements, but using PSWindowsUpdate is easier than the built-in replacements. Go for it.

--
You received this message because you are subscribed to the Google Groups "ntpowershell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntpowershell...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ntpowershell/CY4PR07MB31443E4277472AB0DE0505F1D30F9%40CY4PR07MB3144.namprd07.prod.outlook.com.

Kurt Buff

unread,
Mar 14, 2022, 5:56:13 PM3/14/22
to ntpowe...@googlegroups.com
PSWindowsUpdate will work against remote machines..

Kurt

--

Gordon Pegue

unread,
Mar 15, 2022, 5:08:08 PM3/15/22
to ntpowe...@googlegroups.com

Hey Michael et al –

 

Part of my learning curve with PSWindowsUpdate has included defining TrustedHosts.

 

For the command Set-Item wsman:localhost\client\trustedhosts, can I use the example string *.ou.fabrikam.com to specify the computers that are in an OU?

Can’t seem to find anything on this with google.

I do see how to add everything in the domain (that would be *.fabrikam.com), but our university domain has tens of thousands of computer objects. I only need the computers in my OU (<100).

 

 

TIA

Gordon

 

From: ntpowe...@googlegroups.com <ntpowe...@googlegroups.com> On Behalf Of Michael B. Smith
Sent: Monday, March 14, 2022 3:04 PM
To: ntpowe...@googlegroups.com

Subject: [ntpowershell] RE: Start-WUScan on remote PC

 

  [EXTERNAL]

Michael B. Smith

unread,
Mar 15, 2022, 6:43:20 PM3/15/22
to ntpowe...@googlegroups.com

Mike Leone

unread,
Mar 15, 2022, 9:09:06 PM3/15/22
to NTPowershell Mailing List
I's that necessary for using the PSWindowsUpdate mostly, to scan a remote server? Does that need to be done on the remote server? I've never used the WSMan commands to list a Trusted Host, although I have used that PSWindowsUpdate module to query last Windows Update applied.


Michael B. Smith

unread,
Mar 16, 2022, 7:51:53 AM3/16/22
to ntpowe...@googlegroups.com

No, if everything is in a domain, you only need TrustedHosts if you are trying to identify a “special” class of computers.

Gordon Pegue

unread,
Mar 16, 2022, 11:26:17 AM3/16/22
to ntpowe...@googlegroups.com

Rats. Never an easy way…

 

Read that 1st link article. The *.fabrikam.com example is what made me wonder if it could be more granular to the OU level…

 

So now my question is this:

Is there a potential security risk in leaving the TrustedHosts list populated?

Or should any scripts I code that need it populate it on the fly, use it and then blank it out?

 

Thanks,

Michael B. Smith

unread,
Mar 16, 2022, 11:28:16 AM3/16/22
to ntpowe...@googlegroups.com

What’s your level of paranoia?

 

(Personally, I’m not paranoid enough to blank it after each use – but I do all of this stuff in a separate VM anyway. That’s what I’d recommend.)

Gordon Pegue

unread,
Mar 16, 2022, 11:37:02 AM3/16/22
to ntpowe...@googlegroups.com

Good riposte!

 

For my department (I’m a one-man IT shop), risk is acceptable given physical precautions.

 

I’ve seen both you and Kurt mention the VM-for-admin method before. Methinks it might be time to look into that a bit…

 

Thanks,

Gordon

 

 

From: ntpowe...@googlegroups.com <ntpowe...@googlegroups.com> On Behalf Of Michael B. Smith
Sent: Wednesday, March 16, 2022 9:28 AM
To: ntpowe...@googlegroups.com
Subject: [ntpowershell] RE: Start-WUScan on remote PC

 

  [EXTERNAL]

Kurt Buff

unread,
Mar 16, 2022, 11:45:56 AM3/16/22
to ntpowe...@googlegroups.com
If you're going to use a VM, use that as your daily driver - email, web browsing, other Office apps.

Use the physical host as your admin station.

Why? Because it's a whole lot harder to break out of a VM into a host (especially if the user on the VM isn't privileged) than it is to control a VM from the host (even if the user on the host isn't privileged).

Kurt

Gordon Pegue

unread,
Mar 17, 2022, 5:31:52 PM3/17/22
to ntpowe...@googlegroups.com

In my efforts to construct a script using the tools in PSWindowsUpdate, I’ve come to realize something I can’t seem to puzzle out.

 

It looks like MS, in their infinite wisdom, ties all the recent Windows 10 Feature Update Enablement (FUE) packages to the same darn KB # (KB5011487).

Thus I’m having difficulties coding my script to determine if (say for example) to 20H2 FUE package is _available_ but not yet installed.

 

Right now, my script uses this: (Get-HotFix -Id KB5011487) as part of the conditional.

That doesn’t tell me _which_ FUE package is installed.

 

Tips? Hints?

 

TIA

Gordon

Michael B. Smith

unread,
Mar 17, 2022, 5:57:18 PM3/17/22
to ntpowe...@googlegroups.com

PS C:\scripts> $c = & hostname.exe

 

PS C:\scripts> reg query "\\$c\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v DisplayVersion

 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

    DisplayVersion    REG_SZ    21H2

 

PS C:\scripts> reg query "\\$c\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v UBR

 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

    UBR    REG_DWORD    0x22c

 

PS C:\scripts> reg query "\\$c\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild

 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

    CurrentBuild    REG_SZ    22000

Gordon Pegue

unread,
Mar 17, 2022, 6:40:35 PM3/17/22
to ntpowe...@googlegroups.com

Dang it! A registry dip!p;rovgueprvgojovk

 

Here’s what works in my script:

$r = (Invoke-Command -Session $session -ScriptBlock { Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name "DisplayVersion" }).DisplayVersion

 

Then I can use the $r in my comparison check!

 

Thanks!

Gordon Pegue

unread,
Mar 17, 2022, 6:58:41 PM3/17/22
to ntpowe...@googlegroups.com

Pardon the gibberish after the first !

Not exactly sure what happened there.

Reply all
Reply to author
Forward
0 new messages