mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
25 lines
664 B
PowerShell
25 lines
664 B
PowerShell
|
|
function Set-IcingaAcl()
|
||
|
|
{
|
||
|
|
param(
|
||
|
|
[string]$Directory
|
||
|
|
);
|
||
|
|
|
||
|
|
if (-Not (Test-Path $Directory)) {
|
||
|
|
throw 'Failed to set Acl for directory. Directory does not exist';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
$DirectoryAcl = Get-Acl -Path $Directory;
|
||
|
|
$DirectoryAccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(
|
||
|
|
(Get-IcingaServiceUser),
|
||
|
|
'Modify',
|
||
|
|
'ContainerInherit,ObjectInherit',
|
||
|
|
'None',
|
||
|
|
'Allow'
|
||
|
|
);
|
||
|
|
|
||
|
|
$DirectoryAcl.SetAccessRule($DirectoryAccessRule);
|
||
|
|
Set-Acl -Path $Directory -AclObject $DirectoryAcl;
|
||
|
|
Test-IcingaAcl -Directory $Directory -WriteOutput | Out-Null;
|
||
|
|
}
|