Quantcast
Viewing all articles
Browse latest Browse all 15370

Powershell- need help renaming multiple computers at the same time in our domain

I'm a powershell novice and need assistance with this script. I already created the CSV file with old name, new name in line 1 and the data of old name, new name starting in line 2. When I try running the script, I run into this error.

Script:

$Credential=Get-Credential
$Computers = Import-CSV -Path "C:\RenameComputer.csv"
ForEach ($comp in $Computers){
Rename-Computer -ComputerName $($comp.oldname) -NewName $($comp.newname) -domaincredential $Credential -force
Restart-Computer $($comp.oldname)
}

Error:

Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At line:2 char:35
+ Rename-Computer -ComputerName $($comp.oldname) -NewName $($comp.n ...
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:)...


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>