Setting "Log on as a service" and "Allow logon locally" with ADSI

Robert MacLean picture Robert MacLean · Jun 1, 2009 · Viewed 11.1k times · Source

I am trying to create a powershell script to automate user creation which is working great using ADSI. However I need to set the following properties and I am not sure how (or if ADSI can even do this):

  • Log on as a service
  • Allow logon locally

Any ideas how to do this?

Answer

Robert MacLean picture Robert MacLean · Jun 2, 2009

The solution to working with GPO's in PowerShell is via a COM+ object called GPMgmt.GPM which is part of the Group Policy Management Console feature. The best article for information I could find on this is: http://technet.microsoft.com/en-us/magazine/cc162355.aspx

I have yet to be able to figure out how to set those specific values though.