Skip to content

Commit

Permalink
Get-TssFolderPermission - adding part script
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Feb 26, 2021
1 parent be7b661 commit 94de6e8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
@@ -1,5 +1,5 @@
class TssFolderPermission {
[int]$FolderAccessRoleId
[int]$GroupId
[int]$SecretAccessRole
[int]$SecretAccessRoleId
}
6 changes: 1 addition & 5 deletions src/functions/folder-permissions/Get-FolderPermission.ps1
Expand Up @@ -58,11 +58,7 @@ function Get-FolderPermission {
}

if ($restResponse) {
[TssFolderPermission]@{
FolderAccessRoleId = $restResponse.folderAccessRoleId
GroupId = $restResponse.groupId
SecretAccessRole = $restResponse.secretAccessRoleId
}
. $TssFolderPermissionObject $restResponse
}
}
} else {
Expand Down
31 changes: 31 additions & 0 deletions src/parts/TssFolderPermissionObject.ps1
@@ -0,0 +1,31 @@
<#
.Synopsis
Creates a TssFolderPermission object
#>
param(
[pscustomobject]$Object
)

begin {
$Properties = $Object[0].PSObject.Properties.Name
}

process {
$outObject = @()
foreach ($f in $Object) {
$currentObject = [TssFolderPermission]::new()
foreach ($sProp in $Properties) {
# until bug is fixed in endpoint
if ($sProp -in 'Id','folderId','folderAccessRoleName','SecretAccessRoleName','groupName','userId','userName','knownAs') {
continue
}
if ($sProp -in $currentObject.PSObject.Properties.Name) {
$currentObject.$sProp = $f.$sProp
} else {
Write-Warning "Property $sProp does not exist in the TssFolderPermission class.bug report at https://github.com/thycotic-ps/thycotic.secretserver/issues/new/choose"
}
}
$outObject += $currentObject
}
return $outObject
}

0 comments on commit 94de6e8

Please sign in to comment.