I've been searching for a way to grant the "Logon as a Service" right to a user account with pure PowerShell for a while.  But, I found the same buggy, incomplete code over and over on the Internet.  So, I wrote my own and expanded the functionality.

Current Version: 2.1.07

Benefits:

Requirements:

Available Cmdlets:

 

How to use:

Import the .psm1 file, and use get-help -detailed for syntax on each cmdlet.  Powershell must be running with elevated administrative rights.

PowerShell
Edit|Remove
Import-Module .\UserRights.psm1
 Examples:
PowerShell
Edit|Remove
# Grants Tony "Log on as a service" right 
Grant-UserRight -Account "tony.pombo" -Right SeServiceLogonRight
 
PowerShell
Edit|Remove
# Gets a list of all accounts with "Log on as a service" right 
Get-AccountsWithUserRight -Right SeServiceLogonRight
 
PowerShell
Edit|Remove
# Removes all user rights granted to Guests and Everyone 
Get-UserRightsGrantedToAccount "Guests","Everyone" | Revoke-UserRight 
# Very bad - Don't actually try this!!!!
 Revision History:

Enjoy!