In a script I’m currently writing, I create a dedicated user for starting some windows services that we internally developed. In order to start those services, our “dedicated” user needs the SeServiceLogonRight privilege. Currently, I’m assigning that privilege using ntrights.exe with the following call from my PowerShell script:
{.$global:RootInstallDir\..\Common\SupportTools\ntrights.exe -m $env:COMPUTERNAME -u $HealthLinkUser +r SeServiceLogonRight }
However, I’m not satisfied with this. There must be a cleaner way of doing that with PowerShell.
This worked for me. You can decide which is cleaner 😉 The key is the LsaAddAccountRights windows API function.