title: Run command as System User in Powershell
body: <p>I found several answers on the web, but not really what I was searching for.</p>
  
  <p>The issue is as follows:
  When restoring a file with "Networker", the ACLs of the file are the same ones as when the file was backed up, regardles of inheritance in the folder the file is restored to. Meaning the inheritence of ACL does not affect the newly restored file.</p>
  
  <p>This leaves me with the problem that only 3 Accounts have the right to alter the ACL.</p>
  
  <ul>
  <li>The user, the file belongs to </li>
  <li>The domain Admins </li>
  <li>The system account</li>
  </ul>
  
  <p>To solve the issue I would like to run an automated script fixing the ACL and activating the correct inheritance.</p>
  
  <p>The system user for the script has to be one of the three. 
  The User is changing and thefore not a valid choice, also I dont want to leave any domain admin credentials nor give domain admin rights to a service account.</p>
  
  <p>This leaves me with the system account to do the job and here comes the question:</p>
  
  <p>How do I execute a task in powershell under system account credentials?</p>
  
  <p>I tried</p>
  
  <pre><code>$username = "NT Authority\System"
  $password = ConvertTo-SecureString -String "" -AsPlainText -Force
  $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist @($username, $password)
  </code></pre>
  
  <p>Since the password is an empty I can not really create credentials with it.</p>
  
  <blockquote>
    <p>The name of the account in all locales is .\LocalSystem. The name,
    LocalSystem or ComputerName\LocalSystem can also be used. This account
    does not have a password.
    <a href="https://msdn.microsoft.com/de-de/library/windows/desktop/ms684190(v=vs.85).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/de-de/library/windows/desktop/ms684190(v=vs.85).aspx</a></p>
  </blockquote>
  
  <p>So now I am a little bit confused as to how I can get this to work.</p>
  
  <p>Edit:
  The file system runs on EMC and is not a real Windows File System, but just kinda hooked onto a Linux system. So there is no local administrator account.</p>
  
  <p><strong>TL;DR</strong></p>
  
  <p>I want to inherit ACL Permissions on files using the system account with powershell, how?</p>