fix: handle icacls exit code and copy overwrites
This commit is contained in:
parent
dd57bc9886
commit
4b0bdd7026
1 changed files with 5 additions and 2 deletions
|
|
@ -642,9 +642,12 @@ if (-not (Test-Path '{target}')) {{ New-Item -ItemType Directory -Force -Path '{
|
||||||
$admins = (New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')).Translate([Security.Principal.NTAccount]).Value
|
$admins = (New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')).Translate([Security.Principal.NTAccount]).Value
|
||||||
$localSvc = (New-Object Security.Principal.SecurityIdentifier('S-1-5-19')).Translate([Security.Principal.NTAccount]).Value
|
$localSvc = (New-Object Security.Principal.SecurityIdentifier('S-1-5-19')).Translate([Security.Principal.NTAccount]).Value
|
||||||
takeown /F '{target}' /R /D Y | Out-Null
|
takeown /F '{target}' /R /D Y | Out-Null
|
||||||
if ($LASTEXITCODE -ne 0) {{ exit $LASTEXITCODE }}
|
if ($LASTEXITCODE -ne 0) {{ $take = $LASTEXITCODE }} else {{ $take = 0 }}
|
||||||
icacls '{target}' /grant "${{admins}}":(OI)(CI)F "${{localSvc}}":(OI)(CI)F /T /C | Out-Null
|
icacls '{target}' /grant "${{admins}}":(OI)(CI)F "${{localSvc}}":(OI)(CI)F /T /C | Out-Null
|
||||||
exit $LASTEXITCODE
|
$ica = $LASTEXITCODE
|
||||||
|
if (($take -eq 0) -and ($ica -in 0,1)) {{ exit 0 }}
|
||||||
|
if ($ica -ne 0) {{ exit $ica }}
|
||||||
|
exit $take
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
run_powershell_elevated(&script)
|
run_powershell_elevated(&script)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue