Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $servers = Get-Content C:\Tools\serverList.txt
  2. $creds = Get-Credential
  3.  
  4. ForEach($server in $servers){
  5.  
  6.   $option1 = "/source wu"
  7.   $option2 = "/contenttype criticalonly"
  8.   $option3 = "/restart none"
  9.  
  10.   Copy-Item \\tkfiltoolbox\Tools\23649\3.0.37.2319\ '\\STITSNAPBLD105\C$\localbin' -Recurse -Force
  11.  
  12.   $var = invoke-command -ComputerName $server -ScriptBlock { param($option1,$option2,$option3) C:\localbin\3.0.37.2319\CritFix.exe $option1 $option $option3} -Credential $creds
  13.  
  14. }
  15.  
  16.  <#$computernames = get-content  c:\tools\Serverlist.txt
  17.  foreach ($computername in $computernames)
  18.  {
  19.  $baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$computername)
  20.  $key = $baseKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\")
  21.  $subkeys = $key.GetSubKeyNames()
  22.  $key.Close()
  23.  $baseKey.Close()
  24.  If ($subkeys | Where {$_ -eq "RebootPending"}) 
  25.  {
  26.   Write-Host "There is a pending reboot for" $computername
  27.   Restart-Computer -ComputerName $computername -confirm -Force
  28.  }
  29.  Else 
  30.  {
  31.   Write-Host "No reboot is pending for" $computername
  32.  }
  33.   }#>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement