Skip to content

Commit

Permalink
Further refactoring and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
homotechsual committed Dec 12, 2023
1 parent fb6bd48 commit 71abd11
Show file tree
Hide file tree
Showing 98 changed files with 3,133 additions and 2,507 deletions.
32 changes: 32 additions & 0 deletions .vscode/NinjaOne.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"Wrap selection in begin block": {
"prefix": "wrap-begin",
"body": [
"begin {",
"\t${0:$TM_SELECTED_TEXT}",
"}"
],
"scope": "powershell",
"description": "Wrap selection in begin block"
},
"Wrap selection in process block": {
"prefix": "wrap-process",
"body": [
"process {",
"\t${0:$TM_SELECTED_TEXT}",
"}"
],
"scope": "powershell",
"description": "Wrap selection in process block"
},
"Wrap selection in end block": {
"prefix": "wrap-end",
"body": [
"end {",
"\t${0:$TM_SELECTED_TEXT}",
"}"
],
"scope": "powershell",
"description": "Wrap selection in end block",
},
}
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

Please note that backwards compatibility breaks are prefixed with `{"BC"}` (short for Breaking Change).

## 2023-12-12 - Version 2.0.0-beta8

* Add short aliases to all commandlets.
* Rewrite `Set-NinjaOneNodeRolePolicyAssignment` as `Set-NinjaOneOrganisationPolicies` and allow multiple role/policy assignments at a time.
* Refactor all commandlets to use the "advanced function" template for iterative pipeline support.

## 2023-11-17 - Version 2.0.0-beta7

* Fix the `-userType` parameter on `Get-NinjaOneUsers`.

## 2023-11-17 - Version 2.0.0-beta6

* Fix broken document existence check in `Set-NinjaOneOrganisationDocument`.

## 2023-11-17 - Version 2.0.0-beta5

* Add new `-Scripts` and `-Categories` parameters to `Get-NinjaOneDeviceScriptingOptions` to allow automatic expansion of the results.
* Rewrite `Invoke-NinjaOneDeviceScript` with better error handling and dependency checking.
* Introduce new automated tests for comment-based-help elements.

## 2023-11-17 - Version 2.0.0-beta4

* Fix help links, commandlet names and short names (for documentation).

## 2023-11-16 - Version 2.0.0-beta2

* Fix functions not being re-added to exports after name changes.

## 2023-11-15 - Version 2.0.0-beta1

* {"BC"} Refactoring of error handling to allow PowerShell 5.1 compatibility.
Expand Down
32 changes: 2 additions & 30 deletions Source/NinjaOne.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
'Set-NinjaOneDeviceMaintenance',
'Set-NinjaOneLocation',
'Set-NinjaOneLocationCustomFields',
'Set-NinjaOneNodeRolePolicyAssignment',
'Set-NinjaOneOrganisation',
'Set-NinjaOneOrganisationCustomFields',
'Set-NinjaOneOrganisationDocument',
'Set-NinjaOneOrganisationPolicies',
'Set-NinjaOneTicket',
'Set-NinjaOneWindowsServiceConfiguration',
'Update-NinjaOneWebhook'
Expand All @@ -170,35 +170,7 @@
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-NinjaOneBoards',
'Get-NinjaOneDeviceSoftwareProducts',
'Get-NinjaOneOrganizationCustomFields',
'Get-NinjaRMMOrganisationDocuments',
'Get-NinjaRMMOrganizationDocuments',
'Get-NinjaOneOrganizationDocuments',
'Get-NinjaOneOrganizations',
'New-NinjaOneOrganization',
'Update-NinjaOneOrganization',
'Update-NinjaOneOrganizationDocument'
'Update-NinjaOneOrganisationCustomFields',
'Update-NinjaOneOrganizationCustomFields',
'Set-NinjaOneOrganizationCustomFields',
'Update-NinjaOneLocationCustomFields',
'Update-NinjaOneDeviceCustomFields',
'Get-NinjaOneDevice',
'Set-NinjaOneWebhook',
'Update-NinjaOneDevice',
'Update-NinjaOneDeviceApproval',
'Update-NinjaOneDeviceCustomFields',
'Update-NinjaOneDeviceMaintenance',
'Update-NinjaOneLocation',
'Update-NinjaOneNodeRolePolicyAssignment',
'Update-NinjaOneOrganisation',
'Update-NinjaOneOrganisationCustomFields',
'Update-NinjaOneTicket',
'Update-NinjaOneWindowsServiceConfiguration'
)
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand Down
28 changes: 1 addition & 27 deletions Source/NinjaOne.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,4 @@ foreach ($Function in @($Functions)) {
'us' = 'https://app.ninjarmm.com'
'ca' = 'https://ca.ninjarmm.com'
'us2' = 'https://us2.ninjarmm.com'
}
New-Alias -Name 'Connect-NinjaRMM' -Value 'Connect-NinjaOne'
New-Alias -Name 'Find-NinjaRMMDevices' -Value 'Find-NinjaOneDevices'
New-Alias -Name 'Get-NinjaOneBoards' -Value 'Get-NinjaOneTicketBoards'
New-Alias -Name 'Get-NinjaOneDevice' -Value 'Get-NinjaOneDevices'
New-Alias -Name 'Get-NinjaOneDeviceSoftwareProducts' -Value 'Get-NinjaOneSoftwareProducts'
New-Alias -Name 'Get-NinjaOneOrganizationCustomFields' -Value 'Get-NinjaOneOrganisationCustomFields'
New-Alias -Name 'Get-NinjaOneOrganizationDocuments' -Value 'Get-NinjaOneOrganisationDocuments'
New-Alias -Name 'Get-NinjaOneOrganizations' -Value 'Get-NinjaOneOrganisations'
New-Alias -Name 'New-NinjaOneOrganization' -Value 'New-NinjaOneOrganisation'
New-Alias -Name 'Set-NinjaOneOrganizationCustomFields' -Value 'Set-NinjaOneOrganisationCustomFields'
New-Alias -Name 'Set-NinjaOneWebhook' -Value 'Update-NinjaOneWebhook'
New-Alias -Name 'Update-NinjaOneDevice' -Value 'Set-NinjaOneDevice'
New-Alias -Name 'Update-NinjaOneDeviceApproval' -Value 'Set-NinjaOneDeviceApproval'
New-Alias -Name 'Update-NinjaOneDeviceCustomFields' -Value 'Set-NinjaOneDeviceCustomFields'
New-Alias -Name 'Update-NinjaOneDeviceMaintenance' -Value 'Set-NinjaOneDeviceMaintenance'
New-Alias -Name 'Update-NinjaOneLocation' -Value 'Set-NinjaOneLocation'
New-Alias -Name 'Update-NinjaOneLocationCustomFields' -Value 'Set-NinjaOneLocationCustomFields'
New-Alias -Name 'Update-NinjaOneNodeRolePolicyAssignment' -Value 'Set-NinjaOneNodeRolePolicyAssignment'
New-Alias -Name 'Update-NinjaOneOrganisation' -Value 'Set-NinjaOneOrganisation'
New-Alias -Name 'Update-NinjaOneOrganisationCustomFields' -Value 'Set-NinjaOneOrganisationCustomFields'
New-Alias -Name 'Update-NinjaOneOrganization' -Value 'Set-NinjaOneOrganisation'
New-Alias -Name 'Update-NinjaOneOrganizationCustomFields' -Value 'Set-NinjaOneOrganisationCustomFields'
New-Alias -Name 'Update-NinjaOneOrganizationDocument' -Value 'Update-NinjaOneOrganisationDocument'
New-Alias -Name 'Update-NinjaOneTicket' -Value 'Update-NinjaOneTicket'
New-Alias -Name 'Update-NinjaOneWindowsServiceConfiguration' -Value 'Set-NinjaOneWindowsServiceConfiguration'
Export-ModuleMember -Function $Functions.BaseName -Alias *
}
4 changes: 2 additions & 2 deletions Source/Private/New-NinjaOnePATCHRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function New-NinjaOnePATCHRequest {
[HashTable]$QSCollection,
# A hashtable used to build the body of the request.
[Parameter(Mandatory = $True)]
[Hashtable]$Body
[Object]$Body
)
if ($null -eq $Script:NRAPIConnectionInformation) {
throw "Missing NinjaOne connection information, please run 'Connect-NinjaOne' first."
Expand Down Expand Up @@ -54,7 +54,7 @@ function New-NinjaOnePATCHRequest {
$WebRequestParams = @{
Method = 'PATCH'
Uri = $RequestUri.ToString()
Body = ($Body | ConvertTo-Json -Depth 100)
Body = (ConvertTo-Json -InputObject $Body -Depth 100)
}
Write-Verbose "Raw body is $($WebRequestParams.Body)"
Write-Verbose "Building new NinjaOneRequest with params: $($WebRequestParams | Out-String)"
Expand Down
2 changes: 1 addition & 1 deletion Source/Private/New-NinjaOnePOSTRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function New-NinjaOnePOSTRequest {
}
if ($Body) {
Write-Verbose 'Building [HttpBody] for New-NinjaOnePOSTRequest'
$WebRequestParams.Body = ($Body | ConvertTo-Json -Depth 100)
$WebRequestParams.Body = (ConvertTo-Json -InputObject $Body -Depth 100)
Write-Verbose "Raw body is $($WebRequestParams.Body)"
} else {
Write-Verbose 'No body provided for New-NinjaOnePOSTRequest'
Expand Down
10 changes: 8 additions & 2 deletions Source/Private/New-NinjaOnePUTRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function New-NinjaOnePUTRequest {
[HashTable]$QSCollection,
# A hashtable used to build the body of the request.
[Parameter(Mandatory = $True)]
[Hashtable]$Body,
[Object]$Body,
# Force body to an array.
[Switch]$AsArray
)
Expand Down Expand Up @@ -57,7 +57,13 @@ function New-NinjaOnePUTRequest {
}
if ($Body) {
Write-Verbose 'Building [HttpBody] for New-NinjaOnePUTRequest'
$WebRequestParams.Body = ($Body | ConvertTo-Json -Depth 100)
if ($AsArray) {
Write-Verbose 'Forcing body to array'
$WebRequestParams.Body = (ConvertTo-Json -InputObject @($Body) -Depth 100)
} else {
Write-Verbose 'Not forcing body to array'
$WebRequestParams.Body = (ConvertTo-Json -InputObject $Body -Depth 100)
}
Write-Verbose "Raw body is $($WebRequestParams.Body)"
} else {
Write-Verbose 'No body provided for New-NinjaOnePUTRequest'
Expand Down
Loading

0 comments on commit 71abd11

Please sign in to comment.