How to Set Logon User Rights with the Ntrights.exe in windows 10(64 bit)

10,771

What is an equivalent for ntrights.exe on Windows 10?

Grant, Revoke, Query user rights (privileges) using PowerShell

100% pure PowerShell solution to grant, revoke, and query user rights (privileges), such as "Log on on as a service". Works on local or remote computers.

Download

Description

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.

Benefits:

  • No dependency on external EXE files
  • Can modify any user right; is not limited to "Logon as a Service"
  • Can add/remove rights from the current process token
  • Doesn't write temporary files during operation
  • Fully pipeline-able
  • Pure PowerShell implementation
  • Supports changing user rights on remote machines
  • Fully documented and self contained
  • No code hidden in DLL files or other compiled libraries; fully transparent

Available Cmdlets:

  • Grant-UserRight
  • Revoke-UserRight
  • Get-UserRightsGrantedToAccount
  • Get-AccountsWithUserRight
  • Grant-TokenPrivilege
  • Revoke-TokenPrivilege

How to use:

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

Powershell

# To include from another script: 
Import-Module .\UserRights.ps1 

# or, Dot-Source for use from command prompt: 
.  .\UserRights.ps1

Example:

Powershell

# Grants Tony "Log on as a service" right 
Grant-UserRight tony.pombo SeServiceLogonRight

Powershell

# Gets a list of all accounts with "Log on as a service" right 
Get-AccountsWithUserRight SeServiceLogonRight

Powershell

# Very bad - Don't actually try this!!!!
# Removes all user rights granted to Administrators and Everyone` 
Get-UserRightsGrantedToAccount "Administrators","Everyone" | Revoke-UserRight

source

Share:
10,771

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I need to know whether ntrights.exe 64 bit version exists?

    If not, which is the 64 bit equivalent of ntrights.exe?

    Thanks in advance.

  • Vomit IT - Chunky Mess Style
    Vomit IT - Chunky Mess Style over 4 years
    You can now download Windows Server 2003 Resource Kit Tools and once it installs, check the directory it installs to (e.g. C:\Program Files (x86)\Windows Resource Kits\Tools\) and ntrights.exe will be within there.