Setting "Logon as a Service" and "Allow Logon Locally" using ADSI

I am trying to create a powershell script to automate user creation that works fine using ADSI. However, I need to set the following properties, and I'm not sure how (or if ADSI can do this):

  • Log in as a service
  • Allow local login

Any ideas how to do this?

+6
powershell adsi
source share
3 answers

The PowerShell GPO solution is a COM + object named GPMgmt.GPM that is part of the GPMC function. The best article for information I could find on this: http://technet.microsoft.com/en-us/magazine/cc162355.aspx

I have yet to figure out how to set these specific values.

+5
source share

This may be what you are looking for:

https://gist.github.com/ned1313/9143039

+1
source share

We can set the login right as a user in powershell by importing a third-party DLL (Carbon).

you can download the dll here https://bitbucket.org/splatteredbits/carbon/downloads

$Identity = "DomainName\Administrator" $privilege = "SeServiceLogonRight" $CarbonDllPath = "C:\Users\Administrator\Downloads\Carbon-1.5.1\Carbon\bin\Carbon.dll" [Reflection.Assembly]::LoadFile($CarbonDllPath) [Carbon.Lsa]::GrantPrivileges( $Identity , $privilege ) 
0
source share

All Articles