mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
You can now use 'Add-IcingaWmiPermissions' to add permissions for a specific user and namespace and remove them with 'Remove-IcingaWmiPermissions'
25 lines
600 B
PowerShell
25 lines
600 B
PowerShell
function Get-IcingaUserSID()
|
|
{
|
|
param(
|
|
[string]$User
|
|
);
|
|
|
|
if ($User -eq 'LocalSystem') {
|
|
$User = 'NT Authority\SYSTEM';
|
|
}
|
|
|
|
$UserData = Split-IcingaUserDomain -User $User;
|
|
|
|
try {
|
|
$NTUser = New-Object System.Security.Principal.NTAccount($UserData.Domain, $UserData.User);
|
|
$SecurityData = $NTUser.Translate([System.Security.Principal.SecurityIdentifier]);
|
|
} catch {
|
|
throw $_.Exception;
|
|
}
|
|
|
|
if ($null -eq $SecurityData) {
|
|
throw 'Failed to fetch user information from system';
|
|
}
|
|
|
|
return $SecurityData.Value;
|
|
}
|