mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
win_acl_inheritance: Added tests and formatting improvements (#25382)
This commit is contained in:
parent
c05d3c3821
commit
6d01168238
5 changed files with 240 additions and 27 deletions
|
@ -0,0 +1,44 @@
|
|||
#!powershell
|
||||
|
||||
# WANT_JSON
|
||||
# POWERSHELL_COMMON
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version 2.0
|
||||
|
||||
$params = Parse-Args $args -supports_check_mode $false
|
||||
$path = Get-AnsibleParam -obj $params "path" -type "path" -failifempty $true
|
||||
|
||||
$result = @{
|
||||
changed = $false
|
||||
}
|
||||
|
||||
$acl = Get-Acl -Path $path
|
||||
|
||||
$result.inherited = $acl.AreAccessRulesProtected -eq $false
|
||||
|
||||
$user_details = @{}
|
||||
$acl.Access | ForEach-Object {
|
||||
# Backslashes are the bane of my existance, convert to / to we can export to JSON
|
||||
$user = $_.IdentityReference -replace '\\','/'
|
||||
if ($user_details.ContainsKey($user)) {
|
||||
$details = $user_details.$user
|
||||
} else {
|
||||
$details = @{
|
||||
isinherited = $false
|
||||
isnotinherited = $false
|
||||
}
|
||||
}
|
||||
|
||||
if ($_.IsInherited) {
|
||||
$details.isinherited = $true
|
||||
} else {
|
||||
$details.isnotinherited = $true
|
||||
}
|
||||
|
||||
$user_details.$user = $details
|
||||
}
|
||||
|
||||
$result.user_details = $user_details
|
||||
|
||||
Exit-Json $result
|
Loading…
Add table
Add a link
Reference in a new issue