title: How do I push a PowerShell script out to domain computers?
body: <p>I am trying to run a command that will add a local administrator onto computers. However, I am struggling to combine it with a script to push this out to all domain computers under a particular OU in Active Directory.</p>
  
  <p>Below is the first bit of script is the command I'm using to create the user.</p>
  
  <p>I also have a script to pull all the required OU computers into a CSV, but I need to then push the below script to the PCs in this CSV. Is this possible? 
  I only want it to run the once, not as a start up script as I don't want it to create multiple users.</p>
  
  <pre><code>$Username = "user"
  $Password = "Password"
  $group = "Administrators"
  $adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
  $existing = $adsi.Children | where {
      $_.SchemaClassName -eq 'user' -and $_.Name -eq $Username
  }
  
  if ($existing -eq $null) {
      Write-Host "Creating new local user $Username."
      &amp; NET USER $Username $Password /add /y /expires:never
  
      Write-Host "Adding local user $Username to $group."
      &amp; NET LOCALGROUP $group $Username /add
  }
  
  Write-Host "Ensuring password for $Username never expires."
  &amp; WMIC USERACCOUNT WHERE "Name='$Username'" SET PasswordExpires=FALSE
  </code></pre>