I am trying to run a script to rename remote computers via PowerShell. The problem I'm running into is that I'm getting the following error:
Rename-Computer : Cannot establish the WMI connection to the computer 'computername' with the following error
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
At C:\temp\scripts\rename_script\new_rename.ps1:8 char:5
+ Rename-Computer -NewName $Computer.newname -ComputerName $compute ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (WLA-WS174931:String) [Rename-Computer], InvalidOperationExce
+ FullyQualifiedErrorId : RenameComputerException,Microsoft.PowerShell.Commands.RenameComputerCommand
I am running the command using a domain admin credential from an administrative PowerShell window. I am able to run Get-WMIobject on remote computers successfully. The WMI repository is consistent. I've restarted the WMI service. I can run the command on a local computer with no errors, but trying to run it over the network results in an access denied whether I script it or do it manually. The OS of both target and source systems is Windows 7.
The command I'm using is:
$cred = get-credential
rename-computer -newname newname -computername oldname -domaincredential $cred -restart -passthru -force
I'm a PowerShell/WMI novice, but I feel like I've covered the bases pretty well here. What am I missing?