export users from local policies

Konstantin Nayko 1 Reputation point

Hi all!
Anyone knows easy way to export users with Powershell from secpol.msc -> local policies -> user rights assignment -> Log on as a service?
i can't find any solution.
Thanks for your help

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
4,871 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 22,516 Reputation points Microsoft Vendor


    You can use secedit to export the security settings.

    $file = New-TemporaryFile  
    secedit.exe /export /cfg $file  
    $ServiceLogon = Get-Content -Path $file | Where-Object {$_ -match 'SeServiceLogonRight'}  
    $pattern = '(?<=\*).+?(?=,|$)'  
    [regex]::Matches($ServiceLogon,$pattern).value | ForEach-Object {  
        $SID = New-Object System.Security.Principal.SecurityIdentifier($_)   
            $ErrorActionPreference = "Stop"  
            $SID.Translate( [System.Security.Principal.NTAccount]).Value  
        catch [System.Management.Automation.MethodInvocationException]{  

    Best Regards,
    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments