Powershell: Add User to Login As Batch Job Security Rights

A bit of C# code wrapped up with powershell which will allow you to assign accounts to a local security policy login as batch job rights.

 
 
 
 
 
4.2 Star
(5)
5,923 times
Add to favorites
Operating System
7/17/2015
E-mail Twitter del.icio.us Digg Facebook
  • Update script change languageversion
    1 Posts | Last post January 08, 2020
    • I had to change line 239 to : 
       Add-Type -ErrorAction Stop -Language:CSharp -TypeDefinition $CSharpCode
      change from CSharpVersion3 to CSharp
      I got error Compiler executable file csc.exe cannot be found
      Found solution here https://github.com/proxb/PoshRSJob/issues/23 
      After this it worked (even if I changed the code back to CSharpVersion3 )
      Now it works like a charm. 
      Should the code be updated?
  • Script isn't working
    3 Posts | Last post April 06, 2016
    • Hi,
      
      I am trying to use this script
      
      .\Add-UserToLoginAsBatch.ps1 "domain\username"
      
      This does nothing!
      Even Write-Host Statements are not working.
      
      How do I make this work?
    • By having a look at the actual code you pleb. The script contains a function which means it needs to be dot-sourced like this:
      
      . .\Add-UserToLoginAsBatch.ps1
      
      Then use the function as follows: 
      
      Add-UserToLoginAsBatch.ps1 -UserID "domain\username"
      
    • (Fixed copy/paste error) 
      Then use the function as follows: 
      
      Add-UserToLoginAsBatch -UserID "domain\username"