Mark Minasi's Tech Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Pieter

Avatar / Picture

Senior Member
Registered:
Posts: 199
Reply with quote  #1 
Is it possible to read this information with Powershell (or wmic.exe or another CLI) ?
minasi.jpg  Many thanks.


__________________
Pieter Demeulemeester
0
donoli

Senior Member
Registered:
Posts: 598
Reply with quote  #2 
https://blogs.technet.microsoft.com/charlesa_us/2015/08/06/windows-10-windowsupdate-log-and-how-to-view-it-with-powershell-or-tracefmt-exe/
0
Pieter

Avatar / Picture

Senior Member
Registered:
Posts: 199
Reply with quote  #3 
Thanks Donoli,
But when I use the "Get-WindowsUpdateLog" I get an error.
I tried on a Domain Controller Win2016, PS run As Administrator.


PS C:\> Get-WindowsUpdateLog

Copy-Item : Cannot find path 'C:\Program Files\Windows Defender\SymSrv.dll' because it does not exist.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\WindowsUpdate\WindowsUpdateLog.psm1:56 char:5
+     Copy-Item -Path $SYMSRV_DLL_PATH -Destination $WORKDIR -Force -Er ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Program File...nder\SymSrv.dll:String) [Copy-Item], ItemNotFoundExce
   ption
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand


__________________
Pieter Demeulemeester
0
Pieter

Avatar / Picture

Senior Member
Registered:
Posts: 199
Reply with quote  #4 
I tried it on a member server, also Win2016, and it works. I look at this further.
__________________
Pieter Demeulemeester
0
donoli

Senior Member
Registered:
Posts: 598
Reply with quote  #5 
Ok, good luck w/ it. I imagine that you might be able to d/l the .dll file, for the other server.
0
cj_berlin

Avatar / Picture

Senior Member
Registered:
Posts: 271
Reply with quote  #6 
Hi,

here's what I've been using with great success, albeit not on Windows 10:

Code:

$servers = @('SERVER01','SERVER02','SERVER03')
$script_block = $ExecutionContext.InvokeCommand.NewScriptBlock(@'
$wu_session = New-Object -COM "Microsoft.Update.Session";
$wu_searcher = $wu_session.CreateUpdateSearcher();
$last_instd = ($wu_searcher.QueryHistory(0,1)).Item(0).Date;
$wures = $wu_searcher.Search("IsInstalled=0 and Type='Software'");
$updates_to_install = $wures.Updates.Count;
"$($env:COMPUTERNAME) | $last_instd | $updates_to_install"
'@)
Invoke-Command -ComputerName $servers -ScriptBlock $script_block

__________________
Evgenij Smirnov

My personal blog (German): http://www.it-pro-berlin.de/
My stuff on PSGallery: https://www.powershellgallery.com/profiles/it-pro-berlin.de/
0
Pieter

Avatar / Picture

Senior Member
Registered:
Posts: 199
Reply with quote  #7 
Many thanks Evgenij.

And what about a property (True or False) that represents the "Your device is up to date" in the GUI ?
Would that be possible ?

__________________
Pieter Demeulemeester
0
cj_berlin

Avatar / Picture

Senior Member
Registered:
Posts: 271
Reply with quote  #8 
Quote:
Originally Posted by Pieter
Many thanks Evgenij.

And what about a property (True or False) that represents the "Your device is up to date" in the GUI ?
Would that be possible ?


Well I should expect this condition to be met if the number of updates to be installed is at zero ;-)

__________________
Evgenij Smirnov

My personal blog (German): http://www.it-pro-berlin.de/
My stuff on PSGallery: https://www.powershellgallery.com/profiles/it-pro-berlin.de/
0
Pieter

Avatar / Picture

Senior Member
Registered:
Posts: 199
Reply with quote  #9 
I would expect that too, but that doesn't seems to be true. [confused]

I have two different results : ServerA showing 2 and ServerB showing 1 for $updates_to_install, but on both servers the GUI shows "Your device is up to date".

I have to figure out what's the exact meaning/syntax of the search criteria "Type='Software' and IsInstalled=0".



__________________
Pieter Demeulemeester
0
Donato

Still Checking the Forum Out
Registered:
Posts: 2
Reply with quote  #10 
https://wuinstall.atlassian.net/wiki/spaces/WD/pages/1802257/Criteria+Options

It's not very complete but it mentions a few things.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.