Hey guys, I am needing to find out servers that are pending reboot in a large environment. I put together a one-liner powershell command that will pull the servers I want to check, and I know I want to check a certain registry key, but I don't know how to pipe the information from one command into the other. So here's what I got, if you guys can help me out, I'd appreciate it.
Pull list of servers
$Computers = Get-ADComputer -Filter * -SearchBase 'OU=s,OU=n,dc=o,dc=t' | Where-Object {$_.Name -like '??s*'} | Select Name
Check Registry Key
$val = Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Name "RebootPending" -ErrorAction SilentlyContinue
if($val.RebootPending -eq 1)
{
Write-Host "Pending Reboot"
}
ELSE
{
Write-Host "No Reboot Pending"
}
Pull list of servers
$Computers = Get-ADComputer -Filter * -SearchBase 'OU=s,OU=n,dc=o,dc=t' | Where-Object {$_.Name -like '??s*'} | Select Name
Check Registry Key
$val = Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Name "RebootPending" -ErrorAction SilentlyContinue
if($val.RebootPending -eq 1)
{
Write-Host "Pending Reboot"
}
ELSE
{
Write-Host "No Reboot Pending"
}