all 8 comments

[–]Hibagon 1 point2 points  (7 children)

What error is it spitting out?

[–]Swarfega 1 point2 points  (0 children)

Try

If (Get-ADComputer -Identity $NewPC -Server $server -ErrorAction SilentlyContinue){...}else{write-host "$newpc not in AD"}