Functions/Platforms/Set-PASPlatformPSMConfig.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Function Set-PASPlatformPSMConfig {
    <#
.SYNOPSIS
Update target platform PSM Policy details.

.DESCRIPTION
Allows Vault admins to update the PSM Policy Section of a target platform.

.PARAMETER ID
Numeric ID of target platform

.PARAMETER PSMServerID
PSM server ID linked to the platform

.PARAMETER PSMConnectors
Collection of PSM Connectors to link to the platform

.EXAMPLE
$PSMConfig = Get-PASPlatformPSMConfig -ID 23
$PSMConfig.PSMConnectors += ([PSCustomObject]@{"PSMConnectorID"="PSM-RDP";"Enabled"=$true})
$PSMConfig | Set-PASPlatformPSMConfig -ID 23

Adds PSM-RDP as an additional connection component configured on platform with id of 23

.EXAMPLE
$PSMConfig = Get-PASPlatformPSMConfig -ID 23
$PSMConfig | Set-PASPlatformPSMConfig -ID 23 -PSMServerID PSM-LoadBalancer-EMEA

Updates configured PSMServer on platform with id of 23 to PSM-LoadBalancer-EMEA

.EXAMPLE
$ConnectionComponent = $([PSCustomObject]@{"PSMConnectorID"="PSM-SSH";"Enabled"=$true})
Set-PASPlatformPSMConfig -ID 52 -PSMServerID PSM-LoadBalancer-EMEA -PSMConnectors $ConnectionComponent

Configures platform with ID 42 with connection component PSM-SSH
! Any other Connection Components currently configured will be removed.

.EXAMPLE
Set-PASPlatformPSMConfig -id 42 -PSMServerID PSM-LoadBalancer-EMEA

Clears all configured Connection Components from platform with id of 42
#>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true
        )]
        [int]$ID,

        [parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true
        )]
        [string]$PSMServerID,

        [parameter(
            Mandatory = $false,
            ValueFromPipelinebyPropertyName = $true
        )]
        [PSObject[]]$PSMConnectors
    )

    BEGIN {

        Assert-VersionRequirement -RequiredVersion 11.5

    }#begin

    PROCESS {

        #Create URL for request
        $URI = "$Script:BaseURI/API/Platforms/Targets/$ID/PrivilegedSessionManagement"

        #Request body
        $Body = $PSBoundParameters | Get-PASParameter -ParametersToRemove ID | ConvertTo-Json

        if ($PSCmdlet.ShouldProcess($ID, "Update Platform PSM Config")) {

            #send request to web service
            $result = Invoke-PASRestMethod -Uri $URI -Method PUT -Body $Body -WebSession $Script:WebSession

        }

        If ($null -ne $result) {

            $result

        }

    }#process

    END { }#end

}