mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
parent
7b408b209c
commit
0d6a68ffee
3 changed files with 18 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
function Get-IcingaAgentServicePermission()
|
function Get-IcingaAgentServicePermission()
|
||||||
{
|
{
|
||||||
$SystemPermissions = New-TemporaryFile;
|
$SystemPermissions = New-IcingaTemporaryFile;
|
||||||
$SystemOutput = Start-IcingaProcess -Executable 'secedit.exe' -Arguments ([string]::Format('/export /cfg "{0}.inf"', $SystemPermissions));
|
$SystemOutput = Start-IcingaProcess -Executable 'secedit.exe' -Arguments ([string]::Format('/export /cfg "{0}.inf"', $SystemPermissions));
|
||||||
|
|
||||||
if ($SystemOutput.ExitCode -ne 0) {
|
if ($SystemOutput.ExitCode -ne 0) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ function Set-IcingaAgentServicePermission()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$SystemPermissions = New-TemporaryFile;
|
$SystemPermissions = New-IcingaTemporaryFile;
|
||||||
$ServiceUser = Get-IcingaServiceUser;
|
$ServiceUser = Get-IcingaServiceUser;
|
||||||
$ServiceUserSID = Get-IcingaUserSID $ServiceUser;
|
$ServiceUserSID = Get-IcingaUserSID $ServiceUser;
|
||||||
$SystemContent = Get-IcingaAgentServicePermission;
|
$SystemContent = Get-IcingaAgentServicePermission;
|
||||||
|
|
|
||||||
16
lib/core/tools/New-IcingaTemporaryFile.psm1
Normal file
16
lib/core/tools/New-IcingaTemporaryFile.psm1
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
function New-IcingaTemporaryFile()
|
||||||
|
{
|
||||||
|
[string]$TmpFile = '';
|
||||||
|
[string]$FilePath = '';
|
||||||
|
|
||||||
|
while ($TRUE) {
|
||||||
|
$TmpFile = [string]::Format('tmp_icinga{0}.tmp', (Get-Random));
|
||||||
|
$FilePath = Join-Path $Env:TMP -ChildPath $TmpFile;
|
||||||
|
|
||||||
|
if ((Test-Path $FilePath) -eq $FALSE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (New-Item -Path $FilePath -ItemType File);
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue