diff --git a/ARAH/ARAH.psd1 b/ARAH/ARAH.psd1 index 1d881f2..a9cc889 100644 --- a/ARAH/ARAH.psd1 +++ b/ARAH/ARAH.psd1 @@ -3,7 +3,7 @@ RootModule = 'ARAH.psm1' # Version number of this module. - ModuleVersion = '1.3.8' + ModuleVersion = '1.5.1' # ID used to uniquely identify this module GUID = '5bf61bed-a3da-4550-949a-a869b8dc29c6' @@ -26,7 +26,7 @@ # Modules that must be imported into the global environment prior to importing # this module RequiredModules = @( - @{ ModuleName = 'PSFramework'; ModuleVersion = '1.6.214' } + @{ ModuleName = 'PSFramework'; ModuleVersion = '1.11.343' } ) # Assemblies that must be loaded prior to importing this module diff --git a/ARAH/changelog.md b/ARAH/changelog.md index 74d234d..e36d50a 100644 --- a/ARAH/changelog.md +++ b/ARAH/changelog.md @@ -1,13 +1,32 @@ # Changelog + +## 1.5.1 (2025-04-29) +- Fixed HTTP version from `1.1.0` to `1.1` as PowerShell 7.5 complains otherwise. +- Headers are now cloned. + +## 1.5.0 (2025-04-29) +- Changed RequestModifier execution. +- Added ability to add headers to a request. +- Support for newer HTTP versions added. + ## 1.3.8 (2023-09-08) - - If the result is JSON you can enable converting it to a HashTable with the `Invoke-ARAHRequest -ConvertJsonAsHashtable` switch. This is needed in case of the error `Cannot convert the JSON string because it contains keys with different casing. Please use the -AsHashTable switch instead.` - - File Downloads can be handled +- Depth parameter added to `ConvertTo-Json`. +- Added parameter help for `OutFile`. +- If the result is JSON, you can enable converting it to a HashTable with the `Invoke-ARAHRequest -ConvertJsonAsHashtable` switch. This is needed in case of the error `Cannot convert the JSON string because it contains keys with different casing. Please use the -AsHashTable switch instead.` +- File downloads can now be handled. + ## 1.3.6 (2023-03-03) - - If using a HashTable object for the `Invoke-ARAHRequest -Body` parameter it is only converted to json if the content type matches `json`. +- If using a HashTable object for the `Invoke-ARAHRequest -Body` parameter, it is only converted to JSON if the content type matches `json`. + ## 1.3.5 (2023-01-18) - - Added Parameter/Property SkipCheck to the ARAHConnection class and to Invoke-ARAHRequest - Allows e.g. to skip SSL checks while performing the HTTP requests +- Added `SkipCheck` parameter/property to the `ARAHConnection` class and `Invoke-ARAHRequest`. This allows skipping SSL checks while performing HTTP requests. + +## 1.3.4 +- Added configurable depth for `ConvertTo-Json` calls. +- Added `-WarningAction SilentlyContinue` to all `ConvertTo-Json` calls. + ## 1.1.0 (2021-02-26) - - New: automatic generation of functions based on swagger specs +- New: Automatic generation of functions based on Swagger specs. + ## 1.0.0 (2021-02-22) - - New: Module \ No newline at end of file +- Initial release of the module. \ No newline at end of file diff --git a/ARAH/functions/Invoke-ARAHRequest.ps1 b/ARAH/functions/Invoke-ARAHRequest.ps1 index 38a42f8..e908801 100644 --- a/ARAH/functions/Invoke-ARAHRequest.ps1 +++ b/ARAH/functions/Invoke-ARAHRequest.ps1 @@ -96,6 +96,7 @@ [string]$RequestModifier, [string]$PagingHandler, [switch]$ConvertJsonAsHashtable, + [hashtable]$Headers, [switch]$EnablePaging ) $uri = $connection.webServiceRoot + $path @@ -110,17 +111,22 @@ $SkipCheckAndValidation = ($SkipCheck + $Connection.SkipCheck) | Select-Object -Unique if ($URLParameter) { Write-PSFMessage "Converting UrlParameter to a Request-String and add it to the path" -Level Debug - Write-PSFMessage "$($UrlParameter| ConvertTo-Json -WarningAction SilentlyContinue)" -Level Debug + Write-PSFMessage "$($UrlParameter| ConvertTo-Json -WarningAction SilentlyContinue -Depth 3)" -Level Debug $parameterString = (Get-ARAHEncodedParameterString($URLParameter)) $uri = $uri + '?' + $parameterString.trim("?") } $restAPIParameter = @{ Uri = $Uri method = $Method - Headers = $connection.headers + Headers = $connection.headers.clone() ContentType = $effectiveContentType WebSession = $connection.WebSession Credential = $connection.Credential + HttpVersion = $Connection.HttpVersion + } + if ($Headers){ + Write-PSFMessage "Adding additional headers: $($Headers|ConvertTo-Json -Compress)" + $restAPIParameter.Headers += $Headers } if ($SkipCheckAndValidation.Count -gt 0) { Write-PSFMessage "Skipping the following checks during http request: $($SkipCheckAndValidation|Join-String ',')" @@ -154,7 +160,7 @@ try { If ($RequestModifier) { [PSFScriptBlock]$reqModifierScript = Get-PSFScriptBlock -Name $RequestModifier - $reqModifierScript.InvokeEx($false, $true, $true) + $reqModifierScript.InvokeEx($false, $true, $false) } Write-ARAHCallMessage $restAPIParameter $response = Invoke-WebRequest @restAPIParameter diff --git a/ARAH/internal/classes/ARAHConnection.ps1 b/ARAH/internal/classes/ARAHConnection.ps1 index 915f056..a919136 100644 --- a/ARAH/internal/classes/ARAHConnection.ps1 +++ b/ARAH/internal/classes/ARAHConnection.ps1 @@ -5,6 +5,7 @@ [String]$ServerRoot [String]$WebServiceRoot [String]$AuthenticatedUser + [version]$HttpVersion="1.1" hidden[PSCredential]$Credential hidden[String]$ContentType hidden[Microsoft.PowerShell.Commands.WebRequestSession]$WebSession