Hi,
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($_)
try{
$ErrorActionPreference = "Stop"
$SID.Translate( [System.Security.Principal.NTAccount]).Value
}
catch [System.Management.Automation.MethodInvocationException]{
$SID.Value
}
}
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.