title: Rename-Computer is throwing "access is denied" error but I can't figure out to what
body: <p>I am on a Windows 10 Enterprise machine that is hosting hyperv machines. We will call this "Win10Host".
  One of the virtual machines is "Win10Base" which is a base install of Windows 10 Pro.</p>
  
  <p>I am attempting to run the below from "Win10Host" to rename "Win10Base" and it is failing (errors below).</p>
  
  <pre><code>$secpasswd = ConvertTo-SecureString 'mypassword' -AsPlainText -Force
  $localCreds = New-Object System.Management.Automation.PSCredential ('user', $secpasswd);
  
  $computername = 'Win10Base';
  $VMName = 'Win10BaseNew';
  $VMIP = 'x.x.x.x';  //Redacted, I have used remote desktop to verify this ip is correct.
  
  Rename-Computer -ComputerName $VMIP -LocalCredential $localCreds -NewName $VMName -Verbose;
  </code></pre>
  
  <p>Win10Base is a basic click through windows 10 pro install.
  user is the initial user setup after install.</p>
  
  <h2>At first it was throwing:</h2>
  
  <pre><code>Rename-Computer : Cannot establish the WMI connection to the computer 'Win10Base' 
  with the following error message: Access denied .
  At line:9 char:1
  + Rename-Computer -ComputerName $computername -LocalCredential $localCr ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : OperationStopped: (Win10Base:String) [Rename-Computer], InvalidOperationException
      + FullyQualifiedErrorId : RenameComputerException,Microsoft.PowerShell.Commands.RenameComputerCommand
  </code></pre>
  
  <p>After giving permissions to Remote Desktop, configuring the firewall, giving permissions to "Windows Management Instrumentation" in dcomcnfg, and giving access through wmimgmt.msc to the CIMV2 namespace I have arrived at my current situation.</p>
  
  <h2>Currently the powershell throws:</h2>
  
  <pre><code>Rename-Computer : Fail to rename computer 'Win10Base' to 'Win10BaseNew' 
  due to the following exception: Access is denied.
  At line:9 char:1
  + Rename-Computer -ComputerName $computername -LocalCredential $localCr ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : OperationStopped: (Win10Base:String) [Rename-Computer], InvalidOperationException
      + FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand
  </code></pre>
  
  <h2>Run scenarios:</h2>
  
  <p>On Win10Base ISE - fails with the "access denied".</p>
  
  <p>On Win10Base ISE run as admin - success.</p>
  
  <p>On Win10Host ISE - fails with the "access denied"</p>
  
  <p>On Win10Host ISE run as admin - fails with the "access denied"</p>
  
  <p>As best I can tell user on Win10Base is an administrator.  I even enabled "god mode" to see if I could change the user type to a high level and found it was in the administrators group.</p>
  
  <p>Checking Windows Event logs (Application, Security, Setup, and system) I see nothing to correlate with the current access denied.  Nothing is picked up in DbView as best I can tell.</p>
  
  <p><strong>So any suggestions on where to look next for WHAT access is denied would be greatly appreciated.</strong></p>