File tree Expand file tree Collapse file tree 7 files changed +31
-15
lines changed Expand file tree Collapse file tree 7 files changed +31
-15
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## 2023-12-19 - Version 1.17.0
4+
5+ * Add ` -AsBase64 ` parameter to ` Get-HaloAttachment ` to allow fetching single attachments as base64 encoded strings.
6+
37## 2023-11-17 - Version 1.16.0
48
59* Refactor variables in ` Invoke-HaloRequest ` to avoid scope confusion.
Original file line number Diff line number Diff line change @@ -214,9 +214,11 @@ if ($UpdateManifest) {
214214 Import-Module - Name PlatyPS
215215
216216 # Find Latest Version in Change log.
217- $CHANGELOG = Get-Content - Path " $ ( $PSScriptRoot ) \CHANGELOG.md"
217+ $CHANGELOG = Get-Content - Path " $ ( $PSScriptRoot ) \CHANGELOG.md" - Raw
218218 $MarkdownObject = [Markdown.MAML.Parser.MarkdownParser ]::new()
219- [regex ]$Regex = ' \d\.\d\.\d'
219+ [regex ]$ReleaseRegex = ' #{2}.*\d*\.\d*\.\d*$/m'
220+ $Releases = ($ReleaseRegex.Matches ($MarkdownObject.ParseString ($CHANGELOG ).Children.Spans.Text))
221+ [regex ]$VersionRegex = ' \d*\.\d*\.\d*'
220222 $Versions = $Regex.Matches ($MarkdownObject.ParseString ($CHANGELOG ).Children.Spans.Text) | ForEach-Object { $_.Value }
221223 $ChangeLogVersion = ($Versions | Measure-Object - Maximum).Maximum
222224
@@ -236,7 +238,7 @@ if ($UpdateManifest) {
236238 # Update Manifest file with Release Notes
237239 $CHANGELOG = Get-Content - Path " $ ( $PSScriptRoot ) \CHANGELOG.md"
238240 $MarkdownObject = [Markdown.MAML.Parser.MarkdownParser ]::new()
239- $ReleaseNotes = ((($MarkdownObject.ParseString ($CHANGELOG ).Children.Spans.Text) -Match ' \d \.\d\.\d' ) -Split ' - ' )[1 ]
241+ $ReleaseNotes = ((($MarkdownObject.ParseString ($CHANGELOG ).Children.Spans.Text) -Match ' #{2}.*\d* \.\d* \.\d' ) -Split ' - ' )[1 ]
240242
241243 # Update Module with new version
242244 Update-ModuleManifest - ModuleVersion $ChangeLogVersion - Path " $ ( $PSScriptRoot ) \$ModuleName .psd1" - ReleaseNotes $ReleaseNotes
Original file line number Diff line number Diff line change 2727 "powershell.codeFormatting.whitespaceBetweenParameters" : false ,
2828 "powershell.codeFormatting.whitespaceInsideBrace" : true ,
2929 "editor.codeActionsOnSave" : {
30- "source.fixAll.markdownlint" : true
30+ "source.fixAll.markdownlint" : " explicit "
3131 }
3232 }
3333}
Original file line number Diff line number Diff line change 1212 RootModule = ' .\HaloAPI.psm1'
1313
1414 # Version number of this module.
15- ModuleVersion = ' 1.16 .0'
15+ ModuleVersion = ' 1.17 .0'
1616
1717 # Supported PSEditions
1818 # CompatiblePSEditions = @()
268268 IconUri = ' https://3c3br937rz386088k2z3qqdi-wpengine.netdna-ssl.com/wp-content/uploads/2020/04/HaloIcon-300x300.png'
269269
270270 # ReleaseNotes of this module
271- ReleaseNotes = ' Refactor `Invoke-HaloRequest` to avoid reusing variable names and keep the scope clearer. Fixes breakage with PowerShell 7.4.0 .'
271+ ReleaseNotes = ' Add -AsBase64 to Get-HaloAttachment to return the attachment as a base64 encoded string .'
272272
273273 # Prerelease string of this module
274274 # Prerelease = 'Beta1'
Original file line number Diff line number Diff line change @@ -40,7 +40,10 @@ function Get-HaloAttachment {
4040 [String ]$OutFile ,
4141 # Allow Writing Directly to File, using the specified path and the original file name eg c:\temp\
4242 [Parameter ( ParameterSetName = ' SinglePath' , Mandatory = $True )]
43- [String ]$OutPath
43+ [String ]$OutPath ,
44+ # Return the attachment as a base64 encoded string
45+ [Parameter ( ParameterSetName = ' Single' )]
46+ [Switch ]$AsBase64
4447 )
4548 Invoke-HaloPreFlightCheck
4649 $CommandName = $MyInvocation.MyCommand.Name
@@ -88,11 +91,14 @@ function Get-HaloAttachment {
8891 Write-Verbose " Attempting to output to file $OutFile "
8992 $Path = $OutFile
9093 }
91-
9294 Write-Verbose " Writing File $Path "
9395 $File = [System.IO.FileStream ]::new($Path , [System.IO.FileMode ]::Create)
9496 $File.write ($AttachmentResults.Content , 0 , $AttachmentResults.RawContentLength )
9597 $File.close ()
98+ } elseif ($AsBase64 ) {
99+ Write-Verbose ' Returning base64 encoded string'
100+ $Base64String = [System.Convert ]::ToBase64String($AttachmentResults.Content )
101+ Return $Base64String
96102 } else {
97103 return $AttachmentResults.Content
98104 }
Original file line number Diff line number Diff line change @@ -52,14 +52,18 @@ function Invoke-HaloRequest {
5252 try {
5353 Write-Verbose " Making a $ ( $WebRequestParams.Method ) request to $ ( $WebRequestParams.Uri ) "
5454 $Response = Invoke-WebRequest @WebRequestParams - Headers $RequestHeaders - ContentType ' application/json; charset=utf-8'
55- Write-Debug " Response headers: $ ( $Response.Headers | Out-String ) "
56- Write-Debug " Raw Response: $ ( $Response | Out-String ) "
57- Write-Debug " Response Members: $ ( $Response | Get-Member | Out-String ) "
58- $Success = $True
59- if ($RawResult ) {
60- $Results = $Response
55+ if ($Response ) {
56+ Write-Debug " Response headers: $ ( $Response.Headers | Out-String ) "
57+ Write-Debug " Raw Response: $ ( $Response | Out-String ) "
58+ Write-Debug " Response Members: $ ( $Response | Get-Member | Out-String ) "
59+ $Success = $True
60+ if ($RawResult ) {
61+ $Results = $Response
62+ } else {
63+ $Results = ($Response.Content | ConvertFrom-Json - Depth 100 )
64+ }
6165 } else {
62- $Results = ( $ Response.Content | ConvertFrom-Json - Depth 100 )
66+ Write-Debug ' Response was null. '
6367 }
6468 } catch [Microsoft.PowerShell.Commands.HttpResponseException ] {
6569 $Success = $False
You can’t perform that action at this time.
0 commit comments