Need a PS script to a add service account to log on as a service

Welcome Forums General PowerShell Q&A Need a PS script to a add service account to log on as a service

Viewing 1 reply thread
  • Author
    Posts
    • #210576
      Participant
      Topics: 24
      Replies: 59
      Points: 204
      Rank: Participant

      Good morning!
      Looking for some help need to add to add a service account to log on as a service from a list of servers. No idea how to accomplish this. Any help would be greatly appreciated

      Thank you
      Norm

    • #210636
      Participant
      Topics: 12
      Replies: 523
      Points: 1,214
      Helping Hand
      Rank: Community Hero

      You’re looking to assign the user ‘right’ called ‘SeServiceLogonRight’

      You can backup the local security policy to file using something like

      Start-Process secedit -ArgumentList "/export /areas USER_RIGHTS /cfg $FileName" -Wait -PassThru
      

      Get the user SID using something like

      $Sid = ((Get-LocalUser $userName -EA 1).SID).Value
      

      Modify the Policy (text) file as needed – granting the user(s) as defined by their SID(s) the desired rights
      and finally update the local security policy using something like

      Start-Process secedit -ArgumentList "/configure /db $env:windir\security\database\secedit.sdb /cfg $FileName /areas USER_RIGHTS /log $($FileName.Replace('.inf','.log'))" -Wait -PassThru
      

      Can you put it all together?

Viewing 1 reply thread
  • You must be logged in to reply to this topic.