From dd3638eb1743abb59a63e176a2255df46f7a164b Mon Sep 17 00:00:00 2001 From: Gary Smith Date: Thu, 27 May 2021 16:05:21 +1000 Subject: [PATCH] !Deploy! --- CHANGELOG.md | 2 ++ JSM.Insight/Public/Get-InsightCreds.ps1 | 30 +++++++++++++++++++++++- JSM.Insight/Public/Get-WorkspaceID.ps1 | 29 ++++++++++++++++++++++- JSM.Insight/Public/Set-InsightCreds.ps1 | 31 ------------------------- JSM.Insight/Public/Set-WorkspaceID.ps1 | 29 ----------------------- 5 files changed, 59 insertions(+), 62 deletions(-) delete mode 100644 JSM.Insight/Public/Set-InsightCreds.ps1 delete mode 100644 JSM.Insight/Public/Set-WorkspaceID.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a78f8e..1fc7dfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Format as below (Requires the '### Added' as a header or task fails) ...- Update ReadMe.MD ## [Unreleased] +### Added +- Bug fix ## [1.1] - 2021-05-27 ### Added diff --git a/JSM.Insight/Public/Get-InsightCreds.ps1 b/JSM.Insight/Public/Get-InsightCreds.ps1 index 585eccd..e5ef3fc 100644 --- a/JSM.Insight/Public/Get-InsightCreds.ps1 +++ b/JSM.Insight/Public/Get-InsightCreds.ps1 @@ -1,3 +1,31 @@ Function Get-InsightCreds { - $script:InsightCreds + [CmdletBinding()] + [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')] + param( + [Parameter( Mandatory )] + [ValidateNotNullOrEmpty()] + [Alias('user')] + [string]$Username, + [Parameter( Mandatory )] + [ValidateNotNullOrEmpty()] + [Alias('pass')] + [string]$Password + ) + + begin { + Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" + } + + process { + #Encode Creds + $auth = $username + ':' + $password + $Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth) + $authorizationInfo = [System.Convert]::ToBase64String($Encoded) + $Script:InsightCreds = $authorizationInfo + } + + end { + $authorizationInfo + Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" + } } \ No newline at end of file diff --git a/JSM.Insight/Public/Get-WorkspaceID.ps1 b/JSM.Insight/Public/Get-WorkspaceID.ps1 index d165e0d..124e4e5 100644 --- a/JSM.Insight/Public/Get-WorkspaceID.ps1 +++ b/JSM.Insight/Public/Get-WorkspaceID.ps1 @@ -1,3 +1,30 @@ + function Get-WorkspaceID { - $script:InsightWorkstationID + param ( + [cmdletbinding()] + [uri]$InsightServerUrl, + [string]$InsightCreds = $InsightCreds + ) + + begin { + Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" + $Headers = New-Headers -ExperimentalApi + } + + process { + $Request = [System.UriBuilder]"$InsightServerUrl/rest/servicedeskapi/insight/workspace" + } + + end { + try { + $response = Invoke-RestMethod -Uri $Request.Uri -Headers $headers -Method GET + } + catch { + Write-Error -Message "$($_.Exception.Message)" -ErrorId $_.Exception.Code -Category InvalidOperation + } + $script:InsightWorkstationID = $response.values.workspaceId + $response.values.workspaceId + + Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" + } } diff --git a/JSM.Insight/Public/Set-InsightCreds.ps1 b/JSM.Insight/Public/Set-InsightCreds.ps1 deleted file mode 100644 index 060635d..0000000 --- a/JSM.Insight/Public/Set-InsightCreds.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -Function Set-InsightCreds { - [CmdletBinding()] - [System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')] - param( - [Parameter( Mandatory )] - [ValidateNotNullOrEmpty()] - [Alias('user')] - [string]$Username, - [Parameter( Mandatory )] - [ValidateNotNullOrEmpty()] - [Alias('pass')] - [string]$Password - ) - - begin { - Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" - } - - process { - #Encode Creds - $auth = $username + ':' + $password - $Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth) - $authorizationInfo = [System.Convert]::ToBase64String($Encoded) - - $script:InsightCreds = $authorizationInfo - } - - end { - Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" - } -} \ No newline at end of file diff --git a/JSM.Insight/Public/Set-WorkspaceID.ps1 b/JSM.Insight/Public/Set-WorkspaceID.ps1 deleted file mode 100644 index c636b9c..0000000 --- a/JSM.Insight/Public/Set-WorkspaceID.ps1 +++ /dev/null @@ -1,29 +0,0 @@ - -function Set-WorkspaceID { - param ( - [uri]$InsightServerUrl = $InsightServerUrl, - [string]$InsightCreds = $InsightCreds - ) - - begin { - Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" - $Headers = New-Headers -ExperimentalApi - } - - process { - $Request = [System.UriBuilder]"$InsightServerUrl/rest/servicedeskapi/insight/workspace" - } - - end { - try { - $response = Invoke-RestMethod -Uri $Request.Uri -Headers $headers -Method GET - } - catch { - Write-Error -Message "$($_.Exception.Message)" -ErrorId $_.Exception.Code -Category InvalidOperation - } - - $script:InsightWorkstationID = $response.values.workspaceId - - Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" - } -}