Can I keep Remove-Computer from prompting for a password?

I’m importing a list of computers, then running Remove-Computer to remove them from a domain gracefully (as opposed to Remove-ADComputer which just deletes the machine from AD).

Each time this loops, it prompts for credentials. Any ideas if I can make this request credentials once and then not request them again?

$PCs = Get-Content C:Pathdocument.txt foreach ($PC in $PCs) { Remove-Computer -ComputerName $PC -UnjoinDomaincredential "domainuser" -PassThru -Verbose -Restart } 

submitted by /u/red5_SittingBy
[link] [comments]

Leave a Reply