This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Powershell commands to validate SCCM Windows Update Path

I am using cahunt's template but trying to find and validate the SCCM windows update path it is set to use.

So when I change the path (aka the value it should be looking for) it still comes back as statistic 0, but it seems it is not using my script argument

HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\,WUServer,http://servername:8530

param( 

     [string]$reg, 

     [string]$Key,

     $target_value 

$reg_value = Get-ItemProperty $reg -name $Key

 

Write-Host "Message: '$reg' is currently set to '$reg_value'" 

if ($reg_value -match "$key=$target_value") { 

     Write-Host "Statistic: 0" 

} else { 

     Write-Host "Statistic: 1" 

Exit 0 

Output Result:

Message.Statistic:

'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\' is currently set to '@{WUServer=servername:8530444444444; PSPath=Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\; PSParentPath=Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows; PSChildName=WindowsUpdate; PSDrive=HKLM; PSProvider=Microsoft.PowerShell.Core\Registry}'

Statistic.Statistic:

0