Utiliser et comprendre la recherche ANR
Filtrer efficacement plusieurs attributs en une seule ligne
Les permissions LogonAsBatch (SeBatchLogonRight) et LogonAsService (SeServiceLogonRight) sont des droits d’ouverture de session spéciaux dans Windows, attribués à des comptes utilisateurs ou groupes.
Les informations pour ces permissions sont stockées dans la stratégie de sécurité locale (SECPOL), qui peut être exporté vers un fichier CFG.
Créer un dossier C:\temp\
:
mkdir C:\temp -Force
Exporter la stratégie de sécurité locale vers un fichier CFG :
secedit /export /cfg C:\temp\secpol.cfg
Parser la stratégie locale pour obtenir l’information :
$cfg = Get-Content -Path 'C:\temp\secpol.cfg'
$batchLogon = (($cfg | Select-String 'SeBatchLogonRight') -split '=')[-1]
$serviceLogon = (($cfg | Select-String 'SeServiceLogonRight') -split '=')[-1]
Traduction des SID et affichage des résultats :
Write-Host "Log on as a batch job" -ForegroundColor Yellow
$batchLogon = $batchLogon.Replace('*', '').Trim()
$batchLogon -split ',' | ForEach-Object {
$SID = [System.Security.Principal.SecurityIdentifier]::New($_)
($SID.Translate([System.Security.Principal.NTAccount])).Value
}
Write-Host "Log on as a service" -ForegroundColor Yellow
$serviceLogon = $serviceLogon.Replace('*', '').Trim()
$serviceLogon -split ',' | ForEach-Object {
$SID = [System.Security.Principal.SecurityIdentifier]::New($_)
($SID.Translate([System.Security.Principal.NTAccount])).Value
}
Filtrer efficacement plusieurs attributs en une seule ligne
Commentaires