Reboot Workstation or Server from OU
# Export all Maschines
(Get-ADComputer -Filter * -SearchBase “OU=Server,OU=Machines,OU=ORG,DC=ndsedv,DC=de”).Name | Out-File c:\Temp\Servers.txt
# Export only Workstations
(Get-ADComputer -Filter ‘operatingsystem -notlike “*server*”‘).Name | Out-File C:\Temp\Workstations.txt
# Export only Server
(Get-ADComputer -Filter ‘operatingsystem -like “*server*”‘).Name | Out-File C:\Temp\Servers.txt
# Reboot
Restart-Computer -ComputerName (Get-Content C:\Temp\computers.txt) -Force -ErrorAction SilentlyContinue -ErrorVariable NoRestart
$NoRestart.targetobject | Out-File C:\Temp\NoReboot.txt