@@ -166,11 +166,11 @@ function global:Connect-SGWServer {
166166 Catch {
167167 $ResponseBody = ParseExceptionBody $_.Exception.Response
168168 if ($_.Exception.Message -match " Unauthorized" ) {
169- Write-Error " Authorization for $BaseURI /rest /v1/login with user $ ( $Credential.UserName ) failed"
169+ Write-Error " Authorization for $BaseURI /api /v1/login with user $ ( $Credential.UserName ) failed"
170170 return
171171 }
172172 else {
173- Write-Error " Login to $BaseURI /rest /v1/login failed via HTTP protocol. Exception message: $ ( $_.Exception.Message ) `n $ResponseBody "
173+ Write-Error " Login to $BaseURI /api /v1/login failed via HTTPS protocol. Exception message: $ ( $_.Exception.Message ) `n $ResponseBody "
174174 return
175175 }
176176 }
@@ -188,11 +188,11 @@ function global:Connect-SGWServer {
188188 Catch {
189189 $ResponseBody = ParseExceptionBody $_.Exception.Response
190190 if ($_.Exception.Message -match " Unauthorized" ) {
191- Write-Error " Authorization for $BaseURI /rest /v1/login with user $ ( $Credential.UserName ) failed"
191+ Write-Error " Authorization for $BaseURI /api /v1/login with user $ ( $Credential.UserName ) failed"
192192 return
193193 }
194194 else {
195- Write-Error " Login to $BaseURI /rest /v1/login failed via HTTP protocol. Exception message: $ ( $_.Exception.Message ) `n $ResponseBody "
195+ Write-Error " Login to $BaseURI /api /v1/login failed via HTTP protocol. Exception message: $ ( $_.Exception.Message ) `n $ResponseBody "
196196 return
197197 }
198198 }
@@ -205,57 +205,6 @@ function global:Connect-SGWServer {
205205 return $Server
206206}
207207
208- <#
209- . SYNOPSIS
210- Disconnect from StorageGRID Webscale Management Server
211- . DESCRIPTION
212- Disconnect from StorageGRID Webscale Management Server
213- #>
214- function Global :Disconnect-SGWServer {
215- [CmdletBinding ()]
216-
217- PARAM (
218- [parameter (Mandatory = $False ,
219- Position = 0 ,
220- HelpMessage = " StorageGRID Webscale Management Server object. If not specified, global CurrentSGWServer object will be used." )][PSCustomObject []]$Server
221- )
222-
223- Process {
224- if (! $Server ) {
225- $Server = $Global :CurrentSGWServer
226- $DeleteCurrentSGWServer = $true
227- }
228- if (! $Server ) {
229- Write-Error " No StorageGRID Webscale Management Server found. Please run Connect-SGWServer to continue."
230- }
231-
232- foreach ($Server in $Server ) {
233- $Uri = $Server.BaseURI + ' /api/v1/authorize'
234-
235- try {
236- $Result = Invoke-RestMethod - Method DELETE - Uri $Uri - Headers $Server.Headers
237- }
238- catch {
239- $result = $_.Exception.Response.GetResponseStream ()
240- $reader = New-Object System.IO.StreamReader($result )
241- $reader.BaseStream.Position = 0
242- $reader.DiscardBufferedData ()
243- $responseBody = $reader.ReadToEnd ()
244- if ($responseBody.StartsWith (' {' )) {
245- $responseBody = $responseBody | ConvertFrom-Json | ConvertTo-Json
246- }
247- Write-Error " GET to $Uri failed with status code $ ( $_.Exception.Response.StatusCode ) and response body:`n $responseBody "
248- }
249-
250- if ($DeleteCurrentSGWServer ) {
251- $Global :CurrentSGWServer = $null
252- }
253-
254- Write-Host " Succesfully disconnected from StorageGRID Management Server $ ( $Server.Name ) "
255- }
256- }
257- }
258-
259208<#
260209 . SYNOPSIS
261210 Retrieve all StorageGRID Webscale Accounts
0 commit comments