Suman Nagaraj
Suman Nagaraj

Reputation: 145

Got "Access is denied" when I tried to rename the computer

Rename-Computer -NewName "newname" -DomainCredential CWQWTQ1J\Administrator

CWQWTQ1J is computer name and "Administrator" is the username. I am trying to change the name of the local computer. When I run this cmdlet it throws me an error i.e Access is denied. Is there anything I am missing? It will be grateful if someone helps me. enter image description here

Upvotes: 3

Views: 31574

Answers (2)

Zack A
Zack A

Reputation: 833

Run powershell as admin. If using a remote session run as a domain admin.

# enter domain admin when prompted. This stores them in a variable creds
$Creds = get-credential 

#rename the PC passing the saved credential object:
rename-computer -newname 'pcNewName' -domainCredential $Creds

Upvotes: 1

henrycarteruk
henrycarteruk

Reputation: 13227

If the computer is joined to a Domain you need to specify an account on the Domain (with suitable permissions) in DomainCredential, the local administrator account will not work here.

Rename-Computer -NewName "newname" -DomainCredential "Domain\Administrator"

If the computer is a workgroup computer (not part of a domain), you do not need to specify credentials. The account you run PowerShell with will just needs to be a Local Administrator.

Rename-Computer -NewName "newname"

Upvotes: 4

Related Questions