@@ -4338,14 +4338,14 @@ function global:Connect-SgwServer {
43384338 else {
43394339 $Response = Invoke-RestMethod -SessionVariable "Session" -Method POST -Uri "$( $Server.BaseUri )/authorize" -TimeoutSec 10 -ContentType "application/json" -Body $Body -SkipCertificateCheck:$Server.SkipCertificateCheck
43404340 }
4341-
4341+
43424342 $Server.Headers["Authorization"] = "Bearer $( $Response.data )"
4343-
4343+
43444344 $Server.Session = $Session
43454345 if (($Server.Session.Cookies.GetCookies($Server.BaseUri) | Where-Object { $_.Name -match "CsrfToken" })) {
43464346 $XCsrfToken = $Server.Session.Cookies.GetCookies($Server.BaseUri) | Where-Object { $_.Name -match "CsrfToken" } | Select-Object -ExpandProperty Value
43474347 $Server.Headers["X-Csrf-Token"] = $XCsrfToken
4348- }
4348+ }
43494349 }
43504350 Catch {
43514351 $ResponseBody = ParseErrorForResponseBody $_
@@ -4579,7 +4579,7 @@ function global:Invoke-SgwServerSsoAuthentication {
45794579 $Uri = $Server.BaseUri + "/saml-response"
45804580 $Body = "SAMLResponse=" + [System.Net.WebUtility]::UrlEncode($SAMLResponse) + "&RelayState=" + $AccountId
45814581 $TokenResponse = Invoke-WebRequest -Method POST -Uri $Uri -Session StorageGridSession -ContentType "application/x-www-form-urlencoded" -Body $Body
4582-
4582+
45834583 }
45844584 catch {
45854585 Throw "SAML Authentication failed. Please check your username and password!"
@@ -8088,9 +8088,11 @@ Set-Alias -Name Remove-SgwEsEndpoint -Value Remove-SgwEndpoint
80888088 StorageGRID profile to use for connection.
80898089 .PARAMETER Id
80908090 Endpoint ID.
8091+ .PARAMETER DisplayName
8092+ Endpoint DisplayName
80918093#>
80928094function Global:Remove-SgwEndpoint {
8093- [CmdletBinding()]
8095+ [CmdletBinding(DefaultParameterSetName="ID" )]
80948096
80958097 PARAM (
80968098 [parameter(Mandatory = $False,
@@ -8102,8 +8104,13 @@ function Global:Remove-SgwEndpoint {
81028104 [parameter(Mandatory = $True,
81038105 Position = 2,
81048106 HelpMessage = "Endpoint ID.",
8107+ ParameterSetName = "ID",
81058108 ValueFromPipeline = $True,
8106- ValueFromPipelineByPropertyName = $True)][String]$Id
8109+ ValueFromPipelineByPropertyName = $True)][String]$Id,
8110+ [parameter(Mandatory = $True,
8111+ Position = 3,
8112+ ParameterSetName = "DisplayName",
8113+ HelpMessage = "Endpoint DisplayName.")][String]$DisplayName
81078114 )
81088115
81098116 Begin {
@@ -8133,9 +8140,17 @@ function Global:Remove-SgwEndpoint {
81338140 }
81348141
81358142 Process {
8136- $Uri = $Server.BaseURI + "/org/endpoints/$Id"
81378143 $Method = "DELETE"
81388144
8145+ if ($DisplayName) {
8146+ $Endpoint = Get-SgwEndpoint -DisplayName $DisplayName
8147+ if (!$Endpoint.Id) {
8148+ Throw "Endpoint with DisplayName $DisplayName not found"
8149+ }
8150+ $Id = $Endpoint.Id
8151+ }
8152+ $Uri = $Server.BaseURI + "/org/endpoints/$Id"
8153+
81398154 Try {
81408155 $Response = Invoke-SgwRequest -WebSession $Server.Session -Method $Method -Uri $Uri -Headers $Server.Headers -SkipCertificateCheck:$Server.SkipCertificateCheck
81418156 }
@@ -8162,9 +8177,11 @@ Set-Alias -Name Get-SgwEsEndpoint -Value Get-SgwEndpoint
81628177 StorageGRID profile to use for connection.
81638178 .PARAMETER Id
81648179 Endpoint ID.
8180+ .PARAMETER DisplayName
8181+ Endpoint DisplayName
81658182#>
81668183function Global:Get-SgwEndpoint {
8167- [CmdletBinding()]
8184+ [CmdletBinding(DefaultParameterSetName="ID" )]
81688185
81698186 PARAM (
81708187 [parameter(Mandatory = $False,
@@ -8176,8 +8193,13 @@ function Global:Get-SgwEndpoint {
81768193 [parameter(Mandatory = $True,
81778194 Position = 2,
81788195 HelpMessage = "Endpoint ID.",
8196+ ParameterSetName = "ID",
81798197 ValueFromPipeline = $True,
8180- ValueFromPipelineByPropertyName = $True)][String]$Id
8198+ ValueFromPipelineByPropertyName = $True)][String]$Id,
8199+ [parameter(Mandatory = $True,
8200+ Position = 3,
8201+ ParameterSetName = "DisplayName",
8202+ HelpMessage = "Endpoint DisplayName.")][String]$DisplayName
81818203 )
81828204
81838205 Begin {
@@ -8207,6 +8229,14 @@ function Global:Get-SgwEndpoint {
82078229 }
82088230
82098231 Process {
8232+ if ($DisplayName) {
8233+ $Endpoint = Get-SgwEndpoints | Where-Object { $_.DisplayName -eq $DisplayName } | Select-Object -First 1
8234+ if ($Endpoint.Id) {
8235+ Write-Output $Endpoint
8236+ }
8237+ return
8238+ }
8239+
82108240 $Uri = $Server.BaseURI + "/org/endpoints/$Id"
82118241 $Method = "GET"
82128242
@@ -8222,6 +8252,7 @@ function Global:Get-SgwEndpoint {
82228252 }
82238253}
82248254
8255+
82258256<#
82268257 .SYNOPSIS
82278258 Replaces a single endpoint
@@ -14825,15 +14856,15 @@ function Global:Set-SgwSnmp {
1482514856 [parameter(Mandatory = $False,
1482614857 Position = 5,
1482714858 ValueFromPipelineByPropertyName = $True,
14828- HelpMessage = "SNMP system location")][String]$sysContact,
14859+ HelpMessage = "SNMP system location")][String]$sysContact,
1482914860 [parameter(Mandatory = $False,
1483014861 Position = 6,
1483114862 ValueFromPipelineByPropertyName = $True,
14832- HelpMessage = "default trap community")][String]$trapcommunity,
14863+ HelpMessage = "default trap community")][String]$trapcommunity,
1483314864 [parameter(Mandatory = $False,
1483414865 Position = 7,
1483514866 ValueFromPipelineByPropertyName = $True,
14836- HelpMessage = "1 - enable SNMP authentication traps, 2 - disable SNMP authentication traps (default)")][ValidateRange(1,2)][String]$authtrapenable,
14867+ HelpMessage = "1 - enable SNMP authentication traps, 2 - disable SNMP authentication traps (default)")][ValidateRange(1,2)][String]$authtrapenable,
1483714868 [parameter(Mandatory = $False,
1483814869 Position = 8,
1483914870 ValueFromPipelineByPropertyName = $True,
0 commit comments