Wednesday, October 28, 2015

Granting Log on as a service rights/privileges using PowerShell

Making changes to Local Security Policy using PowerShell has long been a bane to PowerShell developers since the functionality is not readily exposed through PowerShell cmdlets.

Fortunately, a bright PowerShell developer has come up with a way to make modifications to the Local Security Policy (specifically the "Log on as a service" right) using a handy PowerShell script!

You can download the script from here: https://gallery.technet.microsoft.com/scriptcenter/Grant-Log-on-as-a-service-11a50893

The script requires a parameter for the $accountToAdd.  However, if you do not want to specify a parameter when calling this script and simply want to the use currently logged-in user account, then you can simply change the script to the following:

$accountToAdd = $env:USERNAME

That is all there is to it!

No comments:

Post a Comment