From 3ef797b8fbc1d26b51d7637ebb39ff06b8af7cba Mon Sep 17 00:00:00 2001 From: Jacob Ernst Date: Thu, 23 Feb 2023 09:44:25 -0500 Subject: [PATCH 1/6] Create Remove-HaloKBArticle.ps1 --- Public/Remove/Remove-HaloKBArticle.ps1 | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Public/Remove/Remove-HaloKBArticle.ps1 diff --git a/Public/Remove/Remove-HaloKBArticle.ps1 b/Public/Remove/Remove-HaloKBArticle.ps1 new file mode 100644 index 0000000..fdc80b9 --- /dev/null +++ b/Public/Remove/Remove-HaloKBArticle.ps1 @@ -0,0 +1,33 @@ +function Remove-HaloKBArticle { + <# + .SYNOPSIS + Removes a knowledgebase articles from the Halo API. + .DESCRIPTION + Deletes a specific knowledgebase articles from Halo. + .OUTPUTS + A powershell object containing the response. + #> + [cmdletbinding( SupportsShouldProcess = $True, ConfirmImpact = 'High' )] + [OutputType([Object])] + Param( + # The client ID + [Parameter( Mandatory = $True )] + [Alias('KBArticle')] + [int64]$KBArticleID + ) + Invoke-HaloPreFlightCheck + try { + $ObjectToDelete = Get-HaloKBArticle -KBArticleID $KBArticleID + if ($ObjectToDelete) { + if ($PSCmdlet.ShouldProcess("KBArticleID '$($ObjectToDelete.name)')'", 'Delete')) { + $Resource = "api/KBArticle/$($KBArticleID)" + $ClientResults = New-HaloDELETERequest -Resource $Resource + Return $ClientResults + } + } else { + Throw 'Knowledgebase article was not found in Halo to delete.' + } + } catch { + New-HaloError -ErrorRecord $_ + } +} From 188c2447a6c4e059e6f143f97da50e416771a692 Mon Sep 17 00:00:00 2001 From: Jacob Ernst Date: Thu, 23 Feb 2023 09:46:21 -0500 Subject: [PATCH 2/6] Update HaloAPI.psd1 --- HaloAPI.psd1 | 1 + 1 file changed, 1 insertion(+) diff --git a/HaloAPI.psd1 b/HaloAPI.psd1 index 3f81d29..43ab19d 100644 --- a/HaloAPI.psd1 +++ b/HaloAPI.psd1 @@ -185,6 +185,7 @@ 'Remove-HaloContract', 'Remove-HaloCRMNote', 'Remove-HaloItem', + 'Remove-HaloKBArticle', 'Remove-HaloTicket', 'Remove-HaloTicketBatch', 'Remove-HaloTicketRules', From 2c54b5e3da61fbcd1d03c5cafc0234e81455defe Mon Sep 17 00:00:00 2001 From: Jacob Ernst Date: Thu, 23 Feb 2023 09:57:46 -0500 Subject: [PATCH 3/6] Fixed Comment on param --- Public/Remove/Remove-HaloKBArticle.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/Remove/Remove-HaloKBArticle.ps1 b/Public/Remove/Remove-HaloKBArticle.ps1 index fdc80b9..70c8bad 100644 --- a/Public/Remove/Remove-HaloKBArticle.ps1 +++ b/Public/Remove/Remove-HaloKBArticle.ps1 @@ -10,7 +10,7 @@ function Remove-HaloKBArticle { [cmdletbinding( SupportsShouldProcess = $True, ConfirmImpact = 'High' )] [OutputType([Object])] Param( - # The client ID + # The KBArticle ID [Parameter( Mandatory = $True )] [Alias('KBArticle')] [int64]$KBArticleID From 0d8ecc45ae7a801425eff5c40f9dc0344b799920 Mon Sep 17 00:00:00 2001 From: Mikey O'Toole Date: Fri, 10 Mar 2023 19:44:44 +0000 Subject: [PATCH 4/6] Updates> --- .vscode/ltex.dictionary.en-GB.txt | 2 + .vscode/ltex.dictionary.en-US.txt | 1 + .vscode/ltex.hiddenFalsePositives.en-GB.txt | 1 + .vscode/settings.json | 11 +- CHANGELOG.md | 107 ++++++++++++++------ HaloAPI.build.ps1 | 16 +-- HaloAPI.psd1 | 2 +- 7 files changed, 95 insertions(+), 45 deletions(-) create mode 100644 .vscode/ltex.dictionary.en-GB.txt create mode 100644 .vscode/ltex.dictionary.en-US.txt create mode 100644 .vscode/ltex.hiddenFalsePositives.en-GB.txt diff --git a/.vscode/ltex.dictionary.en-GB.txt b/.vscode/ltex.dictionary.en-GB.txt new file mode 100644 index 0000000..1e1225c --- /dev/null +++ b/.vscode/ltex.dictionary.en-GB.txt @@ -0,0 +1,2 @@ +cmdlets +HaloAPI diff --git a/.vscode/ltex.dictionary.en-US.txt b/.vscode/ltex.dictionary.en-US.txt new file mode 100644 index 0000000..f491f6c --- /dev/null +++ b/.vscode/ltex.dictionary.en-US.txt @@ -0,0 +1 @@ +Changelog diff --git a/.vscode/ltex.hiddenFalsePositives.en-GB.txt b/.vscode/ltex.hiddenFalsePositives.en-GB.txt new file mode 100644 index 0000000..8eeeec2 --- /dev/null +++ b/.vscode/ltex.hiddenFalsePositives.en-GB.txt @@ -0,0 +1 @@ +{"rule":"EN_A_VS_AN","sentence":"^\\QSwitch from using \\E(?:Dummy|Ina|Jimmy-)[0-9]+\\Q to \\E(?:Dummy|Ina|Jimmy-)[0-9]+\\Q to fix the actual issue in GitHub #1\nAdd an \\E(?:Dummy|Ina|Jimmy-)[0-9]+\\Q parameter to \\E(?:Dummy|Ina|Jimmy-)[0-9]+\\Q for non-standard authentication routes.\\E$"} diff --git a/.vscode/settings.json b/.vscode/settings.json index 6fc599f..02bebaa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ -{ - "cSpell.words": [ - "PWSH", - "Testand" - ] +{ + "cSpell.words": [ + "authinfo", + "PWSH", + "Testand" + ] } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8421874..78307ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,66 +1,107 @@ # Changelog -* 2022-02-06 +## 2023-03-10 - Version 1.14.0 - Version 1.7.0 - Refactored error handling. +* Add Custom Table endpoints `Get-HaloCustomTable`, `New-HaloCustomTable`, `Remove-HaloCustomTable`. -* 2022-02-03 +## 2023-01-01 - Version 1.13.2 + +* Fix incorrect pluralization of `Get-HaloCustomField`. +* Changes to pipeline and release process. + +## 2023-01-01 - Version 1.13.1 + +* Added `IncludeTenants` Switch to `Get-HaloAzureADConnection` to fix Contact sync script. - Version 1.7.0-beta1 - Fixed authentication bug - Fixed token expiry calculation. +## 2022-11-18 - Version 1.13.0 -* 2022-01-04 +* Adds `Recover-HaloTicket` and `-Deleted` parameter for `Get-HaloTicket`. +* Fix `429` (API rate limiting) response handling. +* Refactor of 429 error handling. +* Increase batch wait to 30 seconds. +* Adds `Remove-HaloItem`. - Version 1.5.0 - New Feature: Added Workday functions +## 2022-09-16 - Version 1.11.1 -* 2021-11-11 +* Fix for `PostedOnly` and `NonPostedOnly` parameters on `Get-HaloInvoice`. - Version 1.4.0 - Fixed: Bug in Get-HaloAsset where some parameters were in the incorrect set. - Fixed: Bug in the token expiry calculation causing too many reconnects. - Fixed: Bug in authentication to trial instances. - Fixed: Bug in billing templates. - New Feature: Added Recurring invoice functions. +## 2022-07-02 - Version 1.10.1 -* 2021-09-03 +* Fix incorrect bug fix reversion affecting batch cmdlets. - Version 1.3.0-Beta5 - Fixes the authentication flow for trial instances. Starts adding pipeline support (Tickets/Actions currently). +## 2022-07-01 - Version 1.10.0 -* 2021-08-25 +* Internal contract change, `Invoke-HaloBatchProcessor` now uses `BatchInput` instead of `Input`. Bugfixes for batch processing. - Version 1.3.0-Beta4 - Uses the `api/authinfo` endpoint to dynamically populate the Authentication URL for all requests now. +## 2022-06-21 - Version 1.9.1 -* 2021-08-25 +* Add `-FullObject` parameter for Sites, batch processing for Actions, Workflows, Custom Fields and expose `Invoke-HaloRequest` for ad hoc requests. - Version 1.3.0-Beta3 - Handle `-AuthURL` with or without a path. +## 2022-03-23 - Version 1.9.0 -* 2021-08-25 +* Adds Software Licences, Asset Types and new automated tests. - Version 1.3.0-Beta2 - Switch from using `-AuthPath` to `-AuthURL` to fix the actual issue in GitHub #1 +## 2022-03-15 - Version 1.8.0 -* 2021-08-25 +* Handle arrays of objects for many New/Set commands. - Version 1.3.0-Beta1 - Add an `-AuthPath` parameter to Connect-HaloAPI for non-standard authentication routes. +## 2022-02-06 - Version 1.7.0 -* 2021-08-24 +* Refactored error handling. - Version 1.2.3 - Fix misnamed function invocation in `Get-HaloClient`. +## 2022-01-04 - Version 1.5.0 -* 2021-08-24 +* New Feature: Added Workday functions - Version 1.2.2 - Remove the attempt to load the `HaloLookup` class in HaloAPI.psm1 as it's not used. +## 2021-11-11 - Version 1.4.0 -* 2021-08-23 +* Fixed: Bug in `Get-HaloAsset` where some parameters were in the incorrect set. +* Fixed: Bug in the token expiry calculation causing too many reconnects. +* Fixed: Bug in authentication to trial instances. +* Fixed: Bug in billing templates. +* New Feature: Added Recurring invoice functions. - Version 1.2.1 - Adds missing classes which were erroneously excluded from the build script. +## 2021-10-01 - Version 1.3.2 -* 2021-08-22 +* Fixed: Token expiry calculation is now correct. - Version 1.2.0 - Changes to error handling for more descriptive and reliable error messages. - Adds validation and dynamic completion classes for Lookups, Custom Button types and Scopes. - Add Custom Buttons endpoint. +## 2021-10-01 - Version 1.3.1 -* 2021-08-12 +* Fixes the authentication flow for trial instances. Starts adding pipeline support (Tickets/Actions currently). +* Uses the `api/authinfo` endpoint to dynamically populate the Authentication URL for all requests now. +* Handle `-AuthURL` with or without a path. +* Switch from using `-AuthPath` to `-AuthURL` to fix the actual issue in GitHub #1 +* Add an `-AuthPath` parameter to `Connect-HaloAPI` for non-standard authentication routes. - Version 1.1.0 - Change to output formats - now outputs the objects/results directly. No more `(Get-HaloAction).actions`. - Add the first two `Remove-` commands. - Leaner more efficient core. +## 2021-08-24 - Version 1.2.3 -* 2021-08-11 +* Fix misnamed function invocation in `Get-HaloClient`. - Version 1.0.2 - Fix a bug with `Get-HaloAsset` when supplying the `AssetID` parameter. +## 2021-08-24 - Version 1.2.2 -* 2021-08-08 - - Version 1.0.1 - Initial release of the HaloAPI PowerShell module. +* Remove the attempt to load the `HaloLookup` class in `HaloAPI.psm1` as it's not used. + +## 2021-08-23 - Version 1.2.1 + +* Adds missing classes which were erroneously excluded from the build script. + +## 2021-08-22 - Version 1.2.0 + +* Changes to error handling for more descriptive and reliable error messages. +* Adds validation and dynamic completion classes for Lookups, Custom Button types and Scopes. +* Add Custom Buttons endpoint. + +## 2021-08-12 - Version 1.1.0 + +* Change to output formats - now outputs the objects/results directly. No more `(Get-HaloAction).actions`. +* Add the first two `Remove-` commands. +* Leaner more efficient core. + +## 2021-08-11 - Version 1.0.2 + +* Fix a bug with `Get-HaloAsset` when supplying the `AssetID` parameter. + +## 2021-08-08 - Version 1.0.1 + +* Initial release of the HaloAPI PowerShell module. \ No newline at end of file diff --git a/HaloAPI.build.ps1 b/HaloAPI.build.ps1 index 2bd4733..ba3877e 100644 --- a/HaloAPI.build.ps1 +++ b/HaloAPI.build.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Build script for HaloAPI module - uses 'Invoke-Build' https://github.com/nightroman/Invoke-Build + Homotechsual portable module build script. #> Param ( [String]$Configuration = 'Development', @@ -12,7 +12,7 @@ Param ( [Switch]$Clean ) -$ModuleName = 'HaloAPI' +$ModuleName = 'NinjaOne' # Use strict mode when building. Set-StrictMode -Version Latest @@ -32,8 +32,12 @@ if ($CopyModuleFiles) { if (-not (Test-Path "$($PSScriptRoot)\Output\$ModuleName")) { New-Item -Path "$($PSScriptRoot)\Output\$ModuleName" -ItemType Directory | Out-Null } - Copy-Item -Path "$($PSScriptRoot)\Classes\" -Filter *.* -Recurse -Destination "$($PSScriptRoot)\Output\$ModuleName" -Force - Copy-Item -Path "$($PSScriptRoot)\Data\" -Filter *.* -Recurse -Destination "$($PSScriptRoot)\Output\$ModuleName" -Force + if (Test-Path -Path "$($PSScriptRoot)\Classes\") { + Copy-Item -Path "$($PSScriptRoot)\Classes\" -Filter *.* -Recurse -Destination "$($PSScriptRoot)\Output\$ModuleName" -Force + } + if (Test-Path -Path "$($PSScriptRoot)\Data\") { + Copy-Item -Path "$($PSScriptRoot)\Data\" -Filter *.* -Recurse -Destination "$($PSScriptRoot)\Output\$ModuleName" -Force + } Copy-Item -Path "$($PSScriptRoot)\Private\" -Filter *.* -Recurse -Destination "$($PSScriptRoot)\Output\$ModuleName" -Force Copy-Item -Path "$($PSScriptRoot)\Public\" -Filter *.* -Recurse -Destination "$($PSScriptRoot)\Output\$ModuleName" -Force @@ -42,8 +46,8 @@ if ($CopyModuleFiles) { "$($PSScriptRoot)\LICENSE.md" "$($PSScriptRoot)\CHANGELOG.md" "$($PSScriptRoot)\README.md" - "$($PSScriptRoot)\HaloAPI.psd1" - "$($PSScriptRoot)\HaloAPI.psm1" + "$($PSScriptRoot)\$ModuleName.psd1" + "$($PSScriptRoot)\$ModuleName.psm1" ) -Destination "$($PSScriptRoot)\Output\$ModuleName" -Force } diff --git a/HaloAPI.psd1 b/HaloAPI.psd1 index 93d8f12..96b2c4d 100644 --- a/HaloAPI.psd1 +++ b/HaloAPI.psd1 @@ -231,7 +231,7 @@ CmdletsToExport = @() # Variables to export from this module - VariablesToExport = '*' + VariablesToExport = @() # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. AliasesToExport = 'Get-HaloArticle', 'New-HaloArticle', 'Set-HaloArticle', 'New-HaloArticleBatch', 'Get-HaloCustomFields', 'Get-HaloWorkflows', 'Get-HaloTabs' From 881f2b09bbc1537a0f965189a208bb904e0e2967 Mon Sep 17 00:00:00 2001 From: Mikey O'Toole Date: Fri, 10 Mar 2023 19:47:35 +0000 Subject: [PATCH 5/6] 1.14.0 - Add Custom Table endpoints. --- HaloAPI.psd1 | 6 ++-- Public/Get/Get-HaloCustomTable.ps1 | 47 ++++++++++++++++++++++++++++++ Public/New/New-HaloCustomTable.ps1 | 25 ++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 Public/Get/Get-HaloCustomTable.ps1 create mode 100644 Public/New/New-HaloCustomTable.ps1 diff --git a/HaloAPI.psd1 b/HaloAPI.psd1 index 002a765..cc55123 100644 --- a/HaloAPI.psd1 +++ b/HaloAPI.psd1 @@ -12,7 +12,7 @@ RootModule = '.\HaloAPI.psm1' # Version number of this module. - ModuleVersion = '1.13.2' + ModuleVersion = '1.14.0' # Supported PSEditions # CompatiblePSEditions = @() @@ -86,6 +86,7 @@ 'Get-HaloCRMNote', 'Get-HaloCustomButton', 'Get-HaloCustomField', + 'Get-HaloCustomTable', 'Get-HaloFAQList', 'Get-HaloField', 'Get-HaloInvoice', @@ -136,6 +137,7 @@ 'New-HaloCRMNote', 'New-HaloCustomButton', 'New-HaloCustomField', + 'New-HaloCustomTable', 'New-HaloCustomFieldBatch', 'New-HaloFAQList', 'New-HaloInvoice', @@ -264,7 +266,7 @@ IconUri = 'https://3c3br937rz386088k2z3qqdi-wpengine.netdna-ssl.com/wp-content/uploads/2020/04/HaloIcon-300x300.png' # ReleaseNotes of this module - ReleaseNotes = 'Bugfixes and improvements.' + ReleaseNotes = 'Add Custom Table endpoints.' # Prerelease string of this module # Prerelease = 'Beta5' diff --git a/Public/Get/Get-HaloCustomTable.ps1 b/Public/Get/Get-HaloCustomTable.ps1 new file mode 100644 index 0000000..ea05277 --- /dev/null +++ b/Public/Get/Get-HaloCustomTable.ps1 @@ -0,0 +1,47 @@ +#Requires -Version 7 +function Get-HaloCustomTable { + <# + .SYNOPSIS + Gets custom tables from the Halo API. + .DESCRIPTION + Retrieves custom tables from the Halo API - supports a variety of filtering parameters. + .OUTPUTS + A powershell object containing the response. + #> + [CmdletBinding( DefaultParameterSetName = 'Multi' )] + [OutputType([Object])] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Uses dynamic parameter parsing.')] + Param( + # Custom Table ID. + [Parameter( ParameterSetName = 'Single', Mandatory = $True )] + [int64]$CustomTableId + ) + Invoke-HaloPreFlightCheck + $CommandName = $MyInvocation.MyCommand.Name + $Parameters = (Get-Command -Name $CommandName).Parameters + # Workaround to prevent the query string processor from adding an 'customtableid=' parameter by removing it from the set parameters. + if ($CustomTableId) { + $Parameters.Remove('CustomTableId') | Out-Null + } + $QSCollection = New-HaloQuery -CommandName $CommandName -Parameters $Parameters + try { + if ($AgentID) { + Write-Verbose "Running in single-custom table mode because '-CustomTableId' was provided." + $Resource = "api/customtable/$($CustomTableId)" + } else { + Write-Verbose 'Running in multi-custom button mode.' + $Resource = 'api/customtable' + } + $RequestParams = @{ + Method = 'GET' + Resource = $Resource + AutoPaginateOff = $True + QSCollection = $QSCollection + ResourceType = 'customtables' + } + $CustomTableResults = New-HaloGETRequest @RequestParams + Return $CustomTableResults + } catch { + New-HaloError -ErrorRecord $_ + } +} \ No newline at end of file diff --git a/Public/New/New-HaloCustomTable.ps1 b/Public/New/New-HaloCustomTable.ps1 new file mode 100644 index 0000000..bcb12ab --- /dev/null +++ b/Public/New/New-HaloCustomTable.ps1 @@ -0,0 +1,25 @@ +Function New-HaloCustomTable { + <# + .SYNOPSIS + Creates a custom table via the Halo API. + .DESCRIPTION + Function to send a custom table creation request to the Halo API + .OUTPUTS + Outputs an object containing the response from the web request. + #> + [CmdletBinding( SupportsShouldProcess = $True )] + [OutputType([Object])] + Param ( + # Object containing properties and values used to create a new custom table. + [Parameter( Mandatory = $True )] + [Object]$CustomTable + ) + Invoke-HaloPreFlightCheck + try { + if ($PSCmdlet.ShouldProcess("Custom Table '$($CustomTable.ctname)'", 'Create')) { + New-HaloPOSTRequest -Object $CustomTable -Endpoint 'customtable' + } + } catch { + New-HaloError -ErrorRecord $_ + } +} \ No newline at end of file From 7484f0715d4cfafe0221af7d6b13e4e6b6b42d62 Mon Sep 17 00:00:00 2001 From: Mikey O'Toole Date: Fri, 10 Mar 2023 19:48:33 +0000 Subject: [PATCH 6/6] 1.14.0 - Add Custom Table endpoints. --- HaloAPI.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HaloAPI.build.ps1 b/HaloAPI.build.ps1 index ba3877e..0fed1d5 100644 --- a/HaloAPI.build.ps1 +++ b/HaloAPI.build.ps1 @@ -12,7 +12,7 @@ Param ( [Switch]$Clean ) -$ModuleName = 'NinjaOne' +$ModuleName = 'HaloAPI' # Use strict mode when building. Set-StrictMode -Version Latest