title: How do I rename a Windows (10) PC using a Powershell command in a generic script?
body: <p>I am trying to rename Windows (10) PC using a PowerShell command in a generic script. Here is what I have so far, but it doesn't work:</p>
  <pre><code>Rename-Computer -NewName &quot;New-Name-Based-On-Script-Parent-Folder&quot; -DomainCredential [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -Restart
  </code></pre>
  <p>I have tried running this in a PowerShell instance with administrator privileges, as well as an administrative instance of PowerShell ISE (after running <code>Set-ExecutionPolicy Bypass -Scope Process</code> of course), but to no avail.</p>
  <p>Ideally, I would like this to run on any Windows PC and rename it according to the name of the parent folder that the script resides in. Any suggestions on what I'm doing wrong? Thanks.</p>