title: Powershell: How do you set the Read/Write Service Principal Name AD Permissions?
body: <p>In Powershell, how do you set the Read/Write Service Principal Name AD user permissions?</p>
  
  <p>Normally during my build process, I use ADSIedit to navigate to that object, and then go through all the security tabs to get down to put a checkmark next to:</p>
  
  <ul>
  <li>Read Service Principal Name</li>
  <li>Write Service Principal Name</li>
  </ul>
  
  <p>But navigating through ADSIedit can take a long time so I'm trying to script the process.  If I have a PowerShell LDAP bind with a new user created, how can I use PowerShell to set both of these properties for this user account?</p>
  
  <p>The following is a hacked out code-snippet of the possible pertinent portions of my install script:</p>
  
  <pre><code>$strDomain = "dc=my,dc=com"
  $objDomain = [ADSI] "LDAP://" + strDomain 
  $strSCCMSQLPW = Read-Host -assecurestring "Please enter a password for the " + $strSCCMSQL + " account: "
  New-ADUser -SamAccountName $strSCCMSQL + -Name $strSCCMSQL -AccountPassword $strSCCMSQLPW -Enabled $true -Path $strUsersOU + "," + $strDomain -PasswordNeverExpires $true
  </code></pre>