Netanel Elhadad
asked on
Get List of PC and Change Name PowerShell script
hello, i want Powershell script that give me list of all the computers in AD with the option of select one of them by number and after it i can change the computer name that i selected.
exsmple:
Get-ADComputer -Filter * -Property * | Select-Object CN
1. WS1
2. WS2
3. WS3
4. WS4
Select a PC: 2
Write-Host "Please enter your new computer name: "
$newname = Read-Host
## netdom renamecomputer $oldname /newname:$newname /userd:* /passwordd:* /usero:* /passwordo:* /reboot:10 /force
Rename-Computer -ComputerName "$oldname" -NewName "$newname" -DomainCredential amal-p\admin -Force -PassThru -Restart
exsmple:
Get-ADComputer -Filter * -Property * | Select-Object CN
1. WS1
2. WS2
3. WS3
4. WS4
Select a PC: 2
Write-Host "Please enter your new computer name: "
$newname = Read-Host
## netdom renamecomputer $oldname /newname:$newname /userd:* /passwordd:* /usero:* /passwordo:* /reboot:10 /force
Rename-Computer -ComputerName "$oldname" -NewName "$newname" -DomainCredential amal-p\admin -Force -PassThru -Restart
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks a lot!!!
$pc = Get-ADComputer -Filter * -Property * | Select-Object CN |
Out-GridView -OutputMode Single -Title 'Select one PC to rename'
$newname = Read-Host 'Please enter your new computer name: '
Rename-Computer -ComputerName $pc.CN -NewName $newname -DomainCredential amal-p\admin -Force -PassThru -Restart