2 Replies Latest reply on Jun 7, 2018 1:38 PM by hpstech

    Powershell commands to validate SCCM Windows Update Path

    cfizz34

      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 

       

      Message.Statistic:

       

      'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\' is currently set to '@{WUServer=http://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