diff --git a/.artifacts/CodeCoverage.xml b/.artifacts/CodeCoverage.xml index 8b13789..585cd28 100644 --- a/.artifacts/CodeCoverage.xml +++ b/.artifacts/CodeCoverage.xml @@ -1 +1,109 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.artifacts/TestResults.xml b/.artifacts/TestResults.xml index dc68d05..b352550 100644 --- a/.artifacts/TestResults.xml +++ b/.artifacts/TestResults.xml @@ -1,927 +1,49 @@  - - + + - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + - - - - - - - - - - - - - at $_.PSObject.Properties.Name | Should -Contain -ExpectedValue 'Examples' -Because 'at least one example is required for each function.', R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 -at <ScriptBlock>, R:\Development\NinjaOne\Tests\NinjaOne.Help.Tests.ps1:48 + + \ No newline at end of file diff --git a/C# Classes/.vs/C# Classes/DesignTimeBuild/.dtbcache.v2 b/C# Classes/.vs/C# Classes/DesignTimeBuild/.dtbcache.v2 index b3893d4..be8a2ea 100644 Binary files a/C# Classes/.vs/C# Classes/DesignTimeBuild/.dtbcache.v2 and b/C# Classes/.vs/C# Classes/DesignTimeBuild/.dtbcache.v2 differ diff --git a/C# Classes/.vs/C# Classes/FileContentIndex/47791917-faeb-486c-9e96-d5fe395af534.vsidx b/C# Classes/.vs/C# Classes/FileContentIndex/47791917-faeb-486c-9e96-d5fe395af534.vsidx deleted file mode 100644 index 4f37150..0000000 Binary files a/C# Classes/.vs/C# Classes/FileContentIndex/47791917-faeb-486c-9e96-d5fe395af534.vsidx and /dev/null differ diff --git a/C# Classes/.vs/C# Classes/FileContentIndex/67bef154-1554-406c-9910-7a7c1b5ae2d0.vsidx b/C# Classes/.vs/C# Classes/FileContentIndex/67bef154-1554-406c-9910-7a7c1b5ae2d0.vsidx new file mode 100644 index 0000000..c583329 Binary files /dev/null and b/C# Classes/.vs/C# Classes/FileContentIndex/67bef154-1554-406c-9910-7a7c1b5ae2d0.vsidx differ diff --git a/C# Classes/.vs/C# Classes/FileContentIndex/815f5a3c-a749-4675-8641-0b34892f06ec.vsidx b/C# Classes/.vs/C# Classes/FileContentIndex/e0da99d8-41ad-4e6f-9be9-69d5dc623c46.vsidx similarity index 80% rename from C# Classes/.vs/C# Classes/FileContentIndex/815f5a3c-a749-4675-8641-0b34892f06ec.vsidx rename to C# Classes/.vs/C# Classes/FileContentIndex/e0da99d8-41ad-4e6f-9be9-69d5dc623c46.vsidx index 428d9a1..e66b078 100644 Binary files a/C# Classes/.vs/C# Classes/FileContentIndex/815f5a3c-a749-4675-8641-0b34892f06ec.vsidx and b/C# Classes/.vs/C# Classes/FileContentIndex/e0da99d8-41ad-4e6f-9be9-69d5dc623c46.vsidx differ diff --git a/C# Classes/.vs/C# Classes/v17/.suo b/C# Classes/.vs/C# Classes/v17/.suo index 4e46c94..2467898 100644 Binary files a/C# Classes/.vs/C# Classes/v17/.suo and b/C# Classes/.vs/C# Classes/v17/.suo differ diff --git a/C# Classes/.vs/ProjectEvaluation/c# classes.metadata.v7.bin b/C# Classes/.vs/ProjectEvaluation/c# classes.metadata.v7.bin index 000475d..c90f4e4 100644 Binary files a/C# Classes/.vs/ProjectEvaluation/c# classes.metadata.v7.bin and b/C# Classes/.vs/ProjectEvaluation/c# classes.metadata.v7.bin differ diff --git a/C# Classes/.vs/ProjectEvaluation/c# classes.projects.v7.bin b/C# Classes/.vs/ProjectEvaluation/c# classes.projects.v7.bin index 0db03f7..a92bf9e 100644 Binary files a/C# Classes/.vs/ProjectEvaluation/c# classes.projects.v7.bin and b/C# Classes/.vs/ProjectEvaluation/c# classes.projects.v7.bin differ diff --git a/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfo.cs b/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfo.cs index 14f6a1a..5cf1c73 100644 --- a/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfo.cs +++ b/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfo.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -14,7 +13,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("MetadataAttribute")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+aa5e0d4c1ca950d1efb0f4903c92e134eb4556df")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b879e06dbf11105d702faf1fe4830bc3d96e2920")] [assembly: System.Reflection.AssemblyProductAttribute("MetadataAttribute")] [assembly: System.Reflection.AssemblyTitleAttribute("MetadataAttribute")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache b/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache index b5c6c16..741fa8b 100644 --- a/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache +++ b/C# Classes/MetadataAttribute/obj/Debug/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache @@ -1 +1 @@ -20831bfb983eef4ba512424c361d82eb2e86c051cb9ab4d664ad233f436c2f26 +f47b9af9a2e311cb28648e74d76325b9d76a07dc26e3a115b603fde7fce44f8c diff --git a/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfo.cs b/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfo.cs index 5915574..1948de6 100644 --- a/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfo.cs +++ b/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfo.cs @@ -14,7 +14,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("MetadataAttribute")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95ffe00f92432edd5afa99b995d6e9e3e2a3a7de")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b879e06dbf11105d702faf1fe4830bc3d96e2920")] [assembly: System.Reflection.AssemblyProductAttribute("MetadataAttribute")] [assembly: System.Reflection.AssemblyTitleAttribute("MetadataAttribute")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache b/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache index c3f5baa..efb38be 100644 --- a/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache +++ b/C# Classes/MetadataAttribute/obj/Release/netstandard2.1/MetadataAttribute.AssemblyInfoInputs.cache @@ -1 +1 @@ -190ac49c64636da9455cb6afdef60f866c3d40eae67ac34624aa75a34e87c346 +bcb134855496168b9a92b7f0384c0e18f0f8ac90a5434183b285571b350e14cd diff --git a/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.cs b/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.cs index 6376406..a49285c 100644 --- a/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.cs +++ b/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.cs @@ -1,12 +1,19 @@ using System.Management.Automation; - -class ValidateNodeRoleId : ValidateEnumeratedArgumentsAttribute { +public class ValidateNodeRoleId : ValidateEnumeratedArgumentsAttribute { protected override void ValidateElement(object element) { if (element is null) { throw new ValidationMetadataException("Element is null."); } - if (((string)element != "auto") && !(element is int)) { - throw new ValidationMetadataException("Element is not 'auto' or an integer."); + if (!(element is int) || !(element is string)) { + throw new ValidationMetadataException("Element is not an integer or string"); + } + + if ((element is int) && (((int)element) < 0)) { + throw new ValidationMetadataException("Element is not a valid integer value"); + } + + if ((element is string) && !((string)element).Equals("auto")) { + throw new ValidationMetadataException("Element string is not equal to auto"); } } } \ No newline at end of file diff --git a/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.csproj b/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.csproj index 567c938..502daa7 100644 --- a/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.csproj +++ b/C# Classes/ValidateNodeRoleId/ValidateNodeRoleId.csproj @@ -8,7 +8,7 @@ + DestinationFolder="..\..\Source\Binaries" /> diff --git a/C# Classes/ValidateNodeRoleId/bin/Release/netstandard2.1/ValidateNodeRoleId.deps.json b/C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.deps.json similarity index 100% rename from C# Classes/ValidateNodeRoleId/bin/Release/netstandard2.1/ValidateNodeRoleId.deps.json rename to C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.deps.json diff --git a/C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.dll b/C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.dll new file mode 100644 index 0000000..40835d8 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.dll differ diff --git a/C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.pdb b/C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.pdb new file mode 100644 index 0000000..fb8c668 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/bin/Debug/netstandard2.1/ValidateNodeRoleId.pdb differ diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.cs b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.cs new file mode 100644 index 0000000..348b87f --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.AssemblyInfo.cs b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.AssemblyInfo.cs new file mode 100644 index 0000000..1713e15 --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("ValidateNodeRoleId")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b879e06dbf11105d702faf1fe4830bc3d96e2920")] +[assembly: System.Reflection.AssemblyProductAttribute("ValidateNodeRoleId")] +[assembly: System.Reflection.AssemblyTitleAttribute("ValidateNodeRoleId")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.AssemblyInfoInputs.cache b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.AssemblyInfoInputs.cache new file mode 100644 index 0000000..fe4b308 --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +41255ad57c5ae932e84f76cfb09da08926fa97fb23e736aeb71d54b5699fd9a3 diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.GeneratedMSBuildEditorConfig.editorconfig b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..04b2851 --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,5 @@ +is_global = true +build_property.RootNamespace = ValidateNodeRoleId +build_property.ProjectDir = R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.assets.cache b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.assets.cache new file mode 100644 index 0000000..096ebe0 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.assets.cache differ diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.AssemblyReference.cache b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.AssemblyReference.cache new file mode 100644 index 0000000..8e79ff7 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.AssemblyReference.cache differ diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.CoreCompileInputs.cache b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..5589fae --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +06ddf70c6dddd6a1a67b51cd9985f4ec481eab0799d886a807101132f3ba6a81 diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.FileListAbsolute.txt b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..d376269 --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.csproj.FileListAbsolute.txt @@ -0,0 +1,11 @@ +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\bin\Debug\netstandard2.1\ValidateNodeRoleId.deps.json +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\bin\Debug\netstandard2.1\ValidateNodeRoleId.dll +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\bin\Debug\netstandard2.1\ValidateNodeRoleId.pdb +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.csproj.AssemblyReference.cache +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.GeneratedMSBuildEditorConfig.editorconfig +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.AssemblyInfoInputs.cache +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.AssemblyInfo.cs +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.csproj.CoreCompileInputs.cache +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.sourcelink.json +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.dll +R:\Development\NinjaOne\C# Classes\ValidateNodeRoleId\obj\Debug\netstandard2.1\ValidateNodeRoleId.pdb diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.dll b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.dll new file mode 100644 index 0000000..40835d8 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.dll differ diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.pdb b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.pdb new file mode 100644 index 0000000..fb8c668 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.pdb differ diff --git a/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.sourcelink.json b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.sourcelink.json new file mode 100644 index 0000000..d1cb578 --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/Debug/netstandard2.1/ValidateNodeRoleId.sourcelink.json @@ -0,0 +1 @@ +{"documents":{"R:\\Development\\NinjaOne\\*":"https://dev.azure.com/MSPsUK/NinjaOne/_apis/git/repositories/NinjaOne/items?api-version=1.0&versionType=commit&version=b879e06dbf11105d702faf1fe4830bc3d96e2920&path=/*"}} \ No newline at end of file diff --git a/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfo.cs b/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfo.cs index 5a6b2b7..e6e1a8e 100644 --- a/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfo.cs +++ b/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfo.cs @@ -14,7 +14,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("ValidateNodeRoleId")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95ffe00f92432edd5afa99b995d6e9e3e2a3a7de")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b879e06dbf11105d702faf1fe4830bc3d96e2920")] [assembly: System.Reflection.AssemblyProductAttribute("ValidateNodeRoleId")] [assembly: System.Reflection.AssemblyTitleAttribute("ValidateNodeRoleId")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfoInputs.cache b/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfoInputs.cache index 06d2168..e9f316a 100644 --- a/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfoInputs.cache +++ b/C# Classes/ValidateNodeRoleId/obj/Release/netstandard2.1/ValidateNodeRoleId.AssemblyInfoInputs.cache @@ -1 +1 @@ -d528d1bca552f80e0c86d032a5c6f38ab964bd941cf87415bd1373c1e1c44266 +6316affa1962707b65c93042272ae4e9d3f83bbb80546aca9b8cbf2bc80d0d4d diff --git a/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.deps.json b/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.deps.json new file mode 100644 index 0000000..3f71954 --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.deps.json @@ -0,0 +1,42 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.1/", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.1": {}, + ".NETStandard,Version=v2.1/": { + "ValidateNodeRoleId/1.0.0": { + "dependencies": { + "PowerShellStandard.Library": "5.1.1" + }, + "runtime": { + "ValidateNodeRoleId.dll": {} + } + }, + "PowerShellStandard.Library/5.1.1": { + "runtime": { + "lib/netstandard2.0/System.Management.Automation.dll": { + "assemblyVersion": "3.0.0.0", + "fileVersion": "5.1.1.0" + } + } + } + } + }, + "libraries": { + "ValidateNodeRoleId/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "PowerShellStandard.Library/5.1.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-e31xJjG+Kjbv6YF3Yq6D4Dl3or8v7LrNF41k3CXrWozW6hR1zcOe5KYuZJaGSiAgLnwP8wcW+I3+IWEzMPZKXQ==", + "path": "powershellstandard.library/5.1.1", + "hashPath": "powershellstandard.library.5.1.1.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.dll b/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.dll new file mode 100644 index 0000000..074fed3 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.dll differ diff --git a/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.pdb b/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.pdb new file mode 100644 index 0000000..14ba799 Binary files /dev/null and b/C# Classes/ValidateNodeRoleId/obj/bin/Debug/netstandard2.1/ValidateNodeRoleId.pdb differ diff --git a/C# Classes/ValidateNodeRoleId/obj/bin/Release/netstandard2.1/ValidateNodeRoleId.deps.json b/C# Classes/ValidateNodeRoleId/obj/bin/Release/netstandard2.1/ValidateNodeRoleId.deps.json new file mode 100644 index 0000000..3f71954 --- /dev/null +++ b/C# Classes/ValidateNodeRoleId/obj/bin/Release/netstandard2.1/ValidateNodeRoleId.deps.json @@ -0,0 +1,42 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.1/", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.1": {}, + ".NETStandard,Version=v2.1/": { + "ValidateNodeRoleId/1.0.0": { + "dependencies": { + "PowerShellStandard.Library": "5.1.1" + }, + "runtime": { + "ValidateNodeRoleId.dll": {} + } + }, + "PowerShellStandard.Library/5.1.1": { + "runtime": { + "lib/netstandard2.0/System.Management.Automation.dll": { + "assemblyVersion": "3.0.0.0", + "fileVersion": "5.1.1.0" + } + } + } + } + }, + "libraries": { + "ValidateNodeRoleId/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "PowerShellStandard.Library/5.1.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-e31xJjG+Kjbv6YF3Yq6D4Dl3or8v7LrNF41k3CXrWozW6hR1zcOe5KYuZJaGSiAgLnwP8wcW+I3+IWEzMPZKXQ==", + "path": "powershellstandard.library/5.1.1", + "hashPath": "powershellstandard.library.5.1.1.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/C# Classes/ValidateNodeRoleId/bin/Release/netstandard2.1/ValidateNodeRoleId.dll b/C# Classes/ValidateNodeRoleId/obj/bin/Release/netstandard2.1/ValidateNodeRoleId.dll similarity index 100% rename from C# Classes/ValidateNodeRoleId/bin/Release/netstandard2.1/ValidateNodeRoleId.dll rename to C# Classes/ValidateNodeRoleId/obj/bin/Release/netstandard2.1/ValidateNodeRoleId.dll diff --git a/C# Classes/ValidateNodeRoleId/bin/Release/netstandard2.1/ValidateNodeRoleId.pdb b/C# Classes/ValidateNodeRoleId/obj/bin/Release/netstandard2.1/ValidateNodeRoleId.pdb similarity index 100% rename from C# Classes/ValidateNodeRoleId/bin/Release/netstandard2.1/ValidateNodeRoleId.pdb rename to C# Classes/ValidateNodeRoleId/obj/bin/Release/netstandard2.1/ValidateNodeRoleId.pdb diff --git a/C# Classes/ValidateStringOrInt/ValidateStringOrInt.cs b/C# Classes/ValidateStringOrInt/ValidateStringOrInt.cs index 37ab62d..fc2e4a2 100644 --- a/C# Classes/ValidateStringOrInt/ValidateStringOrInt.cs +++ b/C# Classes/ValidateStringOrInt/ValidateStringOrInt.cs @@ -1,12 +1,10 @@ using System.Management.Automation; public class ValidateStringOrInt : ValidateEnumeratedArgumentsAttribute { protected override void ValidateElement(object element) { - if (element is null) - { + if (element is null) { throw new ValidationMetadataException("Element is null."); } - if (!(element is string) && !(element is int)) - { + if (!(element is string) && !(element is int)) { throw new ValidationMetadataException("Element is not a string or integer."); } } diff --git a/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs b/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs index af81661..622859b 100644 --- a/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs +++ b/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -14,7 +13,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("ValidateStringOrInt")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95ffe00f92432edd5afa99b995d6e9e3e2a3a7de")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b879e06dbf11105d702faf1fe4830bc3d96e2920")] [assembly: System.Reflection.AssemblyProductAttribute("ValidateStringOrInt")] [assembly: System.Reflection.AssemblyTitleAttribute("ValidateStringOrInt")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache b/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache index f54435d..106e159 100644 --- a/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache +++ b/C# Classes/ValidateStringOrInt/obj/Debug/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache @@ -1 +1 @@ -ff86ea5a1334e68facfb05e836fdb0af1ba36a7532364a8e4e010053df7e5a9e +0e98e4b4ae60bb472de60dcc67d634381f87b51fe1f14ff63335739957173b98 diff --git a/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs b/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs index 986b513..aa1adea 100644 --- a/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs +++ b/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfo.cs @@ -14,7 +14,7 @@ [assembly: System.Reflection.AssemblyCompanyAttribute("ValidateStringOrInt")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95ffe00f92432edd5afa99b995d6e9e3e2a3a7de")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b879e06dbf11105d702faf1fe4830bc3d96e2920")] [assembly: System.Reflection.AssemblyProductAttribute("ValidateStringOrInt")] [assembly: System.Reflection.AssemblyTitleAttribute("ValidateStringOrInt")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache b/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache index ead0ecf..334d254 100644 --- a/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache +++ b/C# Classes/ValidateStringOrInt/obj/Release/netstandard2.1/ValidateStringOrInt.AssemblyInfoInputs.cache @@ -1 +1 @@ -a48eefae3b42b900fda074782b6d8464634b85374c085531074e2bbc6215928f +f60e2d1bb5327f49e5f20fa0ec003f615fe64a14cfbec0d30b0ae66cd1fbfd89 diff --git a/CHANGELOG.md b/CHANGELOG.md index 24130cd..f6e5d66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ Please note that backwards compatibility breaks are prefixed with `{"BC"}` (short for Breaking Change). +## 2024-02-16 - Version 2.0.0-RC3 + +* Fix broken ticket commandlet. +* Remove Client Credentials block on Ticketing GET endpoints (thanks Ninja team and Luke Whitelock!) +* Fix device search commandlet. +* Test suite improvements. +* Fix broken class preventing correct commandlet functionality. +* Start implementing native secret vault support. Present but not entirely functional + +## 2024-01-17 - Version 2.0.0-RC2 + +* Move classes to C# code and compile to DLLs for better portability and reliability. + ## 2024-01-16 - Version 2.0.0-RC1 * Add new commandlets: diff --git a/Source/Binaries/ValidateNodeRoleId.dll b/Source/Binaries/ValidateNodeRoleId.dll index d4d1b05..40835d8 100644 Binary files a/Source/Binaries/ValidateNodeRoleId.dll and b/Source/Binaries/ValidateNodeRoleId.dll differ diff --git a/Source/Private/ConvertTo-UnixEpoch.ps1 b/Source/Private/ConvertTo-UnixEpoch.ps1 index ef77117..8a98639 100644 --- a/Source/Private/ConvertTo-UnixEpoch.ps1 +++ b/Source/Private/ConvertTo-UnixEpoch.ps1 @@ -5,6 +5,8 @@ function ConvertTo-UnixEpoch { .DESCRIPTION Takes a PowerShell DateTime object and returns a Unix Epoch timestamp representing the same date/time. .OUTPUTS + [System.Int] + The Unix Epoch timestamp. #> [CmdletBinding()] diff --git a/Source/Private/Get-NinjaOneKeyVaultInformation.ps1 b/Source/Private/Get-NinjaOneKeyVaultInformation.ps1 new file mode 100644 index 0000000..93b9124 --- /dev/null +++ b/Source/Private/Get-NinjaOneKeyVaultInformation.ps1 @@ -0,0 +1,12 @@ +function Get-NinjaOneKeyVaultInformation { + <# + .SYNOPSIS + Retrieves NinjaOne connection and authentication information from the given Azure Key Vault. + .DESCRIPTION + Handles the reading of NinjaOne connection and authentication information to the given Azure Key Vault. This function is intended to be used internally by the module and should not be called directly. + .OUTPUTS + [System.Void] + + Returns nothing. + #> +} \ No newline at end of file diff --git a/Source/Private/Get-TokenExpiry.ps1 b/Source/Private/Get-TokenExpiry.ps1 index 0bf9233..8a840c7 100644 --- a/Source/Private/Get-TokenExpiry.ps1 +++ b/Source/Private/Get-TokenExpiry.ps1 @@ -5,6 +5,8 @@ function Get-TokenExpiry { .DESCRIPTION Takes the expires in time for an auth token and returns a PowerShell date/time object containing the expiry date/time of the token. .OUTPUTS + [System.DateTime] + A powershell date/time object representing the token expiry. #> [CmdletBinding()] diff --git a/Source/Private/Invoke-NinjaOnePreFlightCheck.ps1 b/Source/Private/Invoke-NinjaOnePreFlightCheck.ps1 index 9f41b2a..c1e8fba 100644 --- a/Source/Private/Invoke-NinjaOnePreFlightCheck.ps1 +++ b/Source/Private/Invoke-NinjaOnePreFlightCheck.ps1 @@ -1,5 +1,23 @@ using namespace System.Management.Automation function Invoke-NinjaOnePreFlightCheck { + <# + .SYNOPSIS + Conducts pre-flight checks for the NinjaOne API. + .DESCRIPTION + Conducts pre-flight checks ensuring that the NinjaOne API connection information is present and that the user is authenticated. + .EXAMPLE + PS> Invoke-NinjaOnePreFlightCheck + + Conducts pre-flight checks for the NinjaOne API. + .EXAMPLE + PS> Invoke-NinjaOnePreFlightCheck -SkipConnectionChecks + + Conducts pre-flight checks for the NinjaOne API, skipping the connection checks. + .OUTPUTS + [System.Void] + + Returns nothing if the checks pass. Otherwise, throws an error. + #> [CmdletBinding()] param( # Skip the connection checks. @@ -22,8 +40,4 @@ function Invoke-NinjaOnePreFlightCheck { } else { Write-Verbose 'Skipping connection checks.' } - if ($PSEdition -eq 'Desktop') { - - - } } \ No newline at end of file diff --git a/Source/Private/Set-NinjaOneKeyVaultInformation.ps1 b/Source/Private/Set-NinjaOneKeyVaultInformation.ps1 new file mode 100644 index 0000000..2137f3a --- /dev/null +++ b/Source/Private/Set-NinjaOneKeyVaultInformation.ps1 @@ -0,0 +1,96 @@ +function Set-NinjaOneKeyVaultInformation { + <# + .SYNOPSIS + Saves NinjaOne connection and authentication information to the given Azure Key Vault. + .DESCRIPTION + Handles the saving of NinjaOne connection and authentication information to the given Azure Key Vault. This function is intended to be used internally by the module and should not be called directly. + .OUTPUTS + [System.Void] + + Returns nothing. + #> + [CmdletBinding()] + [OutputType([System.Void])] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'Private function - no need to support.')] + # Suppress the PSSA warning about using ConvertTo-SecureString with -AsPlainText. There's no viable alternative. + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'No viable alternative.')] + param( + # The authentication mode to use. + [String]$AuthMode, + # The URL of the NinjaRMM instance. + [URI]$URL, + # The NinjaRMM instance name. + [String]$Instance, + # The client ID of the application. + [String]$ClientId, + # The client secret of the application. + [String]$ClientSecret, + # The port to listen on for the authentication callback. + [Int]$AuthListenerPort, + # The authentication scopes to request. + [String]$AuthScopes, + # The redirect URI to use for the authentication callback. + [URI]$RedirectURI, + # Use the Key Vault to store the connection information. + [Parameter(Mandatory)] + [Switch]$UseKeyVault, + # The name of the Key Vault to use. + [String]$VaultName, + # Whether to write updated connection information to Key Vault. + [Switch]$WriteToKeyVault, + # The type of the authentication token. + [String]$Type, + # The access token to use for authentication. + [String]$Access, + # The refresh token to use for authentication. + [String]$Refresh, + # The expiration time of the access token. + [DateTime]$Expires + ) + # Check if the Key Vault exists. + $KeyVault = Get-AzKeyVault -VaultName $VaultName -ErrorAction SilentlyContinue + if ($null -eq $KeyVault) { + Write-Error ('Key Vault {0} does not exist.' -f $VaultName) + exit 1 + } + # Make sure we've been told to write to Key Vault. + if ($false -eq $WriteToKeyVault) { + Write-Error 'WriteToKeyVault must be specified.' + exit 1 + } + # Write the connection information to Key Vault. + $Secrets = @{ + 'NinjaOneAuthMode' = $AuthMode + 'NinjaOneURL' = $URL + 'NinjaOneInstance' = $Instance + 'NinjaOneClientId' = $ClientId + 'NinjaOneClientSecret' = $ClientSecret + 'NinjaOneAuthListenerPort' = $AuthListenerPort + 'NinjaOneAuthScopes' = $AuthScopes + 'NinjaOneRedirectURI' = $RedirectURI + 'NinjaOneType' = $Type + 'NinjaOneAccess' = $Access + 'NinjaOneRefresh' = $Refresh + 'NinjaOneExpires' = $Expires + 'NinjaOneWriteToKeyVault' = $WriteToKeyVault.ToString() + 'NinjaOneUseKeyVault' = $UseKeyVault.ToString() + 'NinjaOneVaultName' = $VaultName + } + foreach ($Secret in $Secrets.GetEnumerator()) { + Write-Verbose ('Processing secret {0} for KeyVault storage.' -f $Secret.Key) + Write-Debug ('Secret {0} has type {1}.' -f $Secret.Key, $Secret.Value.GetType().Name) + Write-Debug ('Secret {0} has value {1}.' -f $Secret.Key, $Secret.Value.ToString()) + $SecretName = $Secret.Key + $SecretValue = $Secret.Value + if ([String]::IsNullOrEmpty($SecretValue) -or ($null -eq $SecretValue)) { + Write-Verbose ('Secret {0} is null. Skipping.' -f $SecretName) + continue + } + $SecretTags = @{ + 'Source' = 'NinjaOne' + } + $SecretValue = ConvertTo-SecureString -AsPlainText -Force -String $SecretValue + Set-AzKeyVaultSecret -VaultName $VaultName -Name $SecretName -SecretValue $SecretValue -Tag $SecretTags -ErrorAction Stop -Verbose:$false -Debug:$false + Write-Verbose ('Secret {0} written to KeyVault.' -f $SecretName) + } +} \ No newline at end of file diff --git a/Source/Private/Update-NinjaOneToken.ps1 b/Source/Private/Update-NinjaOneToken.ps1 index 57eafed..1f25dec 100644 --- a/Source/Private/Update-NinjaOneToken.ps1 +++ b/Source/Private/Update-NinjaOneToken.ps1 @@ -11,17 +11,25 @@ function Update-NinjaOneToken { ClientId = $Script:NRAPIConnectionInformation.ClientId ClientSecret = $Script:NRAPIConnectionInformation.ClientSecret UseClientAuth = $True - ShowTokens = $False + ShowTokens = $Script:NRAPIConnectionInformation.ShowTokens + UseKeyVault = $Script:NRAPIConnectionInformation.UseKeyVault + VaultName = $Script:NRAPIConnectionInformation.VaultName + WriteToKeyVault = $Script:NRAPIConnectionInformation.WriteToKeyVault } - } else { + } elseif ($null -ne $Script:NRAPIAuthenticationInformation.Refresh) { $ReauthParams = @{ Instance = $Script:NRAPIConnectionInformation.Instance ClientId = $Script:NRAPIConnectionInformation.ClientId ClientSecret = $Script:NRAPIConnectionInformation.ClientSecret RefreshToken = $Script:NRAPIAuthenticationInformation.Refresh UseTokenAuth = $True - ShowTokens = $False + ShowTokens = $Script:NRAPIConnectionInformation.ShowTokens + UseKeyVault = $Script:NRAPIConnectionInformation.UseKeyVault + VaultName = $Script:NRAPIConnectionInformation.VaultName + WriteToKeyVault = $Script:NRAPIConnectionInformation.WriteToKeyVault } + } else { + throw 'Unable to refresh authentication token information. Not using client credentials and/or refresh token is missing.' } Connect-NinjaOne @ReauthParams Write-Verbose 'Refreshed authentication token information from NinjaOne.' diff --git a/Source/Public/Connect-NinjaOne.ps1 b/Source/Public/Connect-NinjaOne.ps1 index 1c04101..2ea7ef0 100644 --- a/Source/Public/Connect-NinjaOne.ps1 +++ b/Source/Public/Connect-NinjaOne.ps1 @@ -26,33 +26,40 @@ function Connect-NinjaOne { Param ( # Use the "Authorisation Code" flow with your web browser. [Parameter( Mandatory, ParameterSetName = 'Authorisation Code')] + [Parameter( ParameterSetName = 'Key Vault Write' )] [Switch]$UseWebAuth, # Use the "Token Authentication" flow - useful if you already have a refresh token. [Parameter( Mandatory, ParameterSetName = 'Token Authentication' )] + [Parameter( ParameterSetName = 'Key Vault Write' )] [switch]$UseTokenAuth, # Use the "Client Credentials" flow - useful if you already have a client ID and secret. [Parameter( Mandatory, ParameterSetName = 'Client Credentials' )] + [Parameter( ParameterSetName = 'Key Vault Write' )] [switch]$UseClientAuth, # The NinjaOne instance to connect to. Choose from 'eu', 'oc' or 'us'. [Parameter( Mandatory, ParameterSetName = 'Authorisation Code' )] [Parameter( Mandatory, ParameterSetName = 'Token Authentication' )] [Parameter( Mandatory, ParameterSetName = 'Client Credentials' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Write' )] [ValidateSet('eu', 'oc', 'us', 'ca', 'us2')] [string]$Instance, # The Client Id for the application configured in NinjaOne. [Parameter( Mandatory, ParameterSetName = 'Authorisation Code' )] [Parameter( Mandatory, ParameterSetName = 'Token Authentication' )] [Parameter( Mandatory, ParameterSetName = 'Client Credentials' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Write' )] [String]$ClientId, # The Client Secret for the application configured in NinjaOne. [Parameter( Mandatory, ParameterSetName = 'Authorisation Code' )] [Parameter( Mandatory, ParameterSetName = 'Token Authentication' )] [Parameter( Mandatory, ParameterSetName = 'Client Credentials' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Write' )] [String]$ClientSecret, # The API scopes to request, if this isn't passed the scope is assumed to be "all". Pass a string or array of strings. Limited by the scopes granted to the application in NinjaOne. [Parameter( ParameterSetName = 'Authorisation Code' )] [Parameter( ParameterSetName = 'Token Authentication' )] [Parameter( ParameterSetName = 'Client Credentials' )] + [Parameter( ParameterSetName = 'Key Vault Write' )] [ValidateSet('monitoring', 'management', 'control', 'offline_access')] [String[]]$Scopes, # The redirect URI to use. If not set defaults to 'http://localhost'. Should be a full URI e.g. https://redirect.example.uk:9090/auth @@ -63,26 +70,74 @@ function Connect-NinjaOne { [Int]$Port = 9090, # The refresh token to use for "Token Authentication" flow. [Parameter( ParameterSetName = 'Token Authentication' )] + [Parameter( ParameterSetName = 'Key Vault Write' )] [String]$RefreshToken, # Output the tokens - useful when using "Authorisation Code" flow - to use with "Token Authentication" flow. [Parameter( ParameterSetName = 'Authorisation Code' )] [Parameter( ParameterSetName = 'Token Authentication' )] [Parameter( ParameterSetName = 'Client Credentials' )] - [Switch]$ShowTokens + [Switch]$ShowTokens, + # Use Azure Key Vault to retrieve credentials and store tokens. + [Parameter( ParameterSetName = 'Authorisation Code' )] + [Parameter( ParameterSetName = 'Token Authentication' )] + [Parameter( ParameterSetName = 'Client Credentials' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Write' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Read' )] + [Switch]$UseKeyVault, + # The name of the Azure Key Vault to use. + [Parameter( ParameterSetName = 'Authorisation Code' )] + [Parameter( ParameterSetName = 'Token Authentication' )] + [Parameter( ParameterSetName = 'Client Credentials' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Write' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Read' )] + [String]$VaultName, + # Write updated credentials to Azure Key Vault. + [Parameter( ParameterSetName = 'Authorisation Code' )] + [Parameter( ParameterSetName = 'Token Authentication' )] + [Parameter( ParameterSetName = 'Client Credentials' )] + [Parameter( Mandatory, ParameterSetName = 'Key Vault Write' )] + [Parameter( ParameterSetName = 'Key Vault Read')] + [Switch]$WriteToKeyVault, + # Read the authentication information from Azure Key Vault. + [Parameter( ParameterSetName = 'Key Vault Read' )] + [Switch]$ReadFromKeyVault ) process { # Run the pre-flight check. Invoke-NinjaOnePreFlightCheck -SkipConnectionChecks + # Test for Azure Key Vault module. + if ($UseKeyVault) { + if (-not (Get-Module -Name 'Az.KeyVault' -ListAvailable)) { + Write-Error 'Azure Key Vault module not installed, please install the module and try again.' + exit 1 + } + # Test that we have an Azure context. + if (-not (Get-AzContext -Verbose:$false -Debug:$false)) { + Write-Error 'No Azure context found, please run Connect-AzAccount and try again.' + exit 1 + } else { + if ((Get-AzContext -Verbose:$false -Debug:$false).Account.Type -eq 'User') { + Write-Information 'Connected to Azure as a user, using Azure Key Vault to store credentials.' + } elseif ((Get-AzContext -Verbose:$false -Debug:$false).Account.Type -eq 'ManagedService') { + Write-Information 'Connected to Azure as a managed service, using Azure Key Vault to store credentials.' + } + } + if ($ReadFromKeyVault) { + Get-NinjaOneKeyVaultInformation -VaultName $VaultName + } + } # Set the default scopes if they're not passed. - if ($PSCmdlet.ParameterSetName -eq 'Client Credentials' -and $null -eq $Scopes) { + if ($UseClientAuth -and $null -eq $Scopes) { $Scopes = @('monitoring', 'management', 'control') - } elseif (($PSCmdlet.ParameterSetName -eq 'Authorisation Code' -or $PSCmdlet.ParameterSetName -eq 'Token Authentication') -and $null -eq $Scopes) { + } elseif (($UseWebAuth -or $UseTokenAuth) -and $null -eq $Scopes) { $Scopes = @('monitoring', 'management', 'control', 'offline_access') } # Convert scopes to space separated string if it's an array. if ($Scopes -is [System.Array]) { + Write-Verbose ('Scopes are an array, converting to space separated string.') $AuthScopes = $Scopes -Join ' ' } else { + Write-Verbose ('Scopes are a string, using as is.') $AuthScopes = $Scopes } # Get the NinjaOne instance URL. @@ -98,22 +153,46 @@ function Connect-NinjaOne { } else { $RedirectURI = New-Object System.UriBuilder -ArgumentList 'http', 'localhost', $Port } + # Determine the authentication mode. + if ($UseWebAuth -and $Scopes -notcontains 'offline_access') { + $AuthMode = 'Authorisation Code' + } elseif ($UseTokenAuth -or ($UseWebAuth -and $Scopes -contains 'offline_access')) { + $AuthMode = 'Token Authentication' + } elseif ($UseClientAuth) { + $AuthMode = 'Client Credentials' + } # Build a script-scoped variable to hold the connection information. - $ConnectionInformation = @{ - AuthMode = $PSCmdlet.ParameterSetName - URL = $URL - Instance = $Instance - ClientId = $ClientId - ClientSecret = $ClientSecret - AuthListenerPort = $Port - AuthScopes = $AuthScopes - RedirectURI = $RedirectURI + if ($null -eq $Script:NRAPIConnectionInformation) { + $ConnectionInformation = @{ + AuthMode = $AuthMode + URL = $URL + Instance = $Instance + ClientId = $ClientId + ClientSecret = $ClientSecret + AuthListenerPort = $Port + AuthScopes = $AuthScopes + RedirectURI = $RedirectURI + UseKeyVault = $UseKeyVault + VaultName = $VaultName + WriteToKeyVault = $WriteToKeyVault + } + Set-Variable -Name 'NRAPIConnectionInformation' -Value $ConnectionInformation -Visibility Private -Scope Script -Force } - Set-Variable -Name 'NRAPIConnectionInformation' -Value $ConnectionInformation -Visibility Private -Scope Script -Force Write-Verbose "Connection information set to: $($Script:NRAPIConnectionInformation | Format-List | Out-String)" - $AuthenticationInformation = [HashTable]@{} - # Set a script-scoped variable to hold authentication information. - Set-Variable -Name 'NRAPIAuthenticationInformation' -Value $AuthenticationInformation -Visibility Private -Scope Script -Force + if ($null -eq $Script:NRAPIAuthenticationInformation) { + $AuthenticationInformation = [HashTable]@{} + # Set a script-scoped variable to hold authentication information. + Set-Variable -Name 'NRAPIAuthenticationInformation' -Value $AuthenticationInformation -Visibility Private -Scope Script -Force + } + if ($Script.NRAPIConnectionInformation.AuthMode -eq 'Token Authentication' -and $null -eq $UseTokenAuth) { + $UseTokenAuth = $true + } + if ($Script.NRAPIConnectionInformation.AuthMode -eq 'Client Credentials' -and $null -eq $UseClientAuth) { + $UseClientAuth = $true + } + if ($Script.NRAPIConnectionInformation.AuthMode -eq 'Authorisation Code' -and $null -eq $UseWebAuth) { + $UseWebAuth = $true + } if ($UseWebAuth) { # NinjaOne authorisation request query params. $AuthRequestParams = @{ @@ -121,7 +200,7 @@ function Connect-NinjaOne { client_id = $Script:NRAPIConnectionInformation.ClientId client_secret = $Script:NRAPIConnectionInformation.ClientSecret redirect_uri = $Script:NRAPIConnectionInformation.RedirectURI.ToString() - state = $GUId + state = $GUID } if ($Script:NRAPIConnectionInformation.AuthScopes) { $AuthRequestParams.scope = $Script:NRAPIConnectionInformation.AuthScopes @@ -211,6 +290,28 @@ function Connect-NinjaOne { Write-Output $($Script:NRAPIAuthenticationInformation | Format-Table -AutoSize) Write-Output ' SAVE THESE IN A SECURE LOCATION ' } + # If we're using Azure Key Vault, store the authentication information we need. + if ($Script:NRAPIConnectionInformation.UseKeyVault -and $Script:NRAPIConnectionInformation.WriteToKeyVault) { + $KeyVaultParams = @{ + AuthMode = $Script:NRAPIConnectionInformation.AuthMode + URL = $Script:NRAPIConnectionInformation.URL + Instance = $Script:NRAPIConnectionInformation.Instance + ClientId = $Script:NRAPIConnectionInformation.ClientId + ClientSecret = $Script:NRAPIConnectionInformation.ClientSecret + AuthListenerPort = $Script:NRAPIConnectionInformation.AuthListenerPort + AuthScopes = $Script:NRAPIConnectionInformation.AuthScopes + RedirectURI = $Script:NRAPIConnectionInformation.RedirectURI.ToString() + UseKeyVault = $Script:NRAPIConnectionInformation.UseKeyVault + VaultName = $Script:NRAPIConnectionInformation.VaultName + WriteToKeyVault = $Script:NRAPIConnectionInformation.WriteToKeyVault + Type = $Script:NRAPIAuthenticationInformation.Type + Access = $Script:NRAPIAuthenticationInformation.Access + Expires = $Script:NRAPIAuthenticationInformation.Expires + Refresh = $Script:NRAPIAuthenticationInformation.Refresh + } + Write-Verbose 'Using Azure Key Vault to store credentials.' + $ConnectionInformation = Set-NinjaOneKeyVaultInformation @KeyVaultParams + } } catch { throw } diff --git a/Source/Public/Find/Find-NinjaOneDevices.ps1 b/Source/Public/Find/Find-NinjaOneDevices.ps1 index 418a698..34257d7 100644 --- a/Source/Public/Find/Find-NinjaOneDevices.ps1 +++ b/Source/Public/Find/Find-NinjaOneDevices.ps1 @@ -43,7 +43,7 @@ function Find-NinjaOneDevices { } process { try { - Write-Verbose ('Searching for upto {0} devices matching {1}.') -f $limit, $searchQuery + Write-Verbose ('Searching for upto {0} devices matching {1}.' -f $limit, $searchQuery) $QSCollection = New-NinjaOneQuery -CommandName $CommandName -Parameters $Parameters $Resource = 'v2/devices/search' $RequestParams = @{ diff --git a/Source/Public/Get/Backup/Get-NinjaOneBackupJobs.ps1 b/Source/Public/Get/Backup/Get-NinjaOneBackupJobs.ps1 index 456b7cf..e9f65c0 100644 --- a/Source/Public/Get/Backup/Get-NinjaOneBackupJobs.ps1 +++ b/Source/Public/Get/Backup/Get-NinjaOneBackupJobs.ps1 @@ -11,6 +11,58 @@ function Get-NinjaOneBackupJobs { PS> Get-NinjaOneBackupJobs Gets all backup jobs. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -status 'RUNNING' + + Gets all backup jobs with a status of 'RUNNING'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -status 'RUNNING', 'COMPLETED' + + Gets all backup jobs with a status of 'RUNNING' or 'COMPLETED'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -statusFilter 'status = RUNNING' + + Gets all backup jobs with a status of 'RUNNING'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -statusFilter 'status in (RUNNING, COMPLETED)' + + Gets all backup jobs with a status of 'RUNNING' or 'COMPLETED'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -planType 'IMAGE' + + Gets all backup jobs with a plan type of 'IMAGE'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -planType 'IMAGE', 'FILE_FOLDER' + + Gets all backup jobs with a plan type of 'IMAGE' or 'FILE_FOLDER'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -planTypeFilter 'planType = IMAGE' + + Gets all backup jobs with a plan type of 'IMAGE'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -planTypeFilter 'planType in (IMAGE, FILE_FOLDER)' + + Gets all backup jobs with a plan type of 'IMAGE' or 'FILE_FOLDER'. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -startTimeBetween (Get-Date).AddDays(-1), (Get-Date) + + Gets all backup jobs with a start time between 24 hours ago and now. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -startTimeAfter (Get-Date).AddDays(-1) + + Gets all backup jobs with a start time after 24 hours ago. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -startTimeFilter 'startTime between(2024-01-01T00:00:00.000Z,2024-01-02T00:00:00.000Z)' + + Gets all backup jobs with a start time between 2024-01-01T00:00:00.000Z and 2024-01-02T00:00:00.000Z. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -startTimeFilter 'startTime after 2024-01-01T00:00:00.000Z' + + Gets all backup jobs with a start time after 2024-01-01T00:00:00.000Z. + .EXAMPLE + PS> Get-NinjaOneBackupJobs -deviceFilter all + + Gets all backup jobs for the all devices. Includes active and deleted devices. .OUTPUTS A powershell object containing the response. .LINK @@ -102,30 +154,7 @@ function Get-NinjaOneBackupJobs { } process { try { - Write-Verbose 'Getting organisation from NinjaOne API.' - $Organisation = Get-NinjaOneOrganisations -organisationId $organisationId - if ($Organisation) { - Write-Verbose 'Getting location from NinjaOne API.' - if ($locationId) { - $Location = Get-NinjaOneLocations -organisationId $organisationId | Where-Object -Property id -EQ -Value $locationId - if ($Location) { - Write-Verbose ('Getting backup usage for location {0} in organisation {1}.' -f $location.name, $organisation.name) - $Resource = ('v2/organization/{0}/locations/{1}/backup/usage' -f $organisationId, $locationId) - } else { - throw ('Location with id {0} not found in organisation {1}' -f $locationId, $Organisation.Name) - } - } else { - $Locations = Get-NinjaOneLocations -organisationId $organisationId - if ($Organisation -and $Locations) { - Write-Verbose ('Getting backup usage for all locations in organisation {0}.' -f $organisation.name) - $Resource = ('v2/organization/{0}/locations/backup/usage' -f $organisationId) - } else { - throw ('Organisation {0} does not have any locations.' -f $Organisation.Name) - } - } - } else { - throw ('Organisation with id {0} not found.' -f $organisationId) - } + $Resource = '/v2/backup/jobs' $RequestParams = @{ Resource = $Resource QSCollection = $QSCollection diff --git a/Source/Public/Get/Ticketing/Get-NinjaOneContacts.ps1 b/Source/Public/Get/Ticketing/Get-NinjaOneContacts.ps1 index e18e2ae..2030ba0 100644 --- a/Source/Public/Get/Ticketing/Get-NinjaOneContacts.ps1 +++ b/Source/Public/Get/Ticketing/Get-NinjaOneContacts.ps1 @@ -25,10 +25,6 @@ function Get-NinjaOneContacts { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Uses dynamic parameter parsing.')] Param() begin { - if ($Script:NRAPIConnectionInformation.AuthMode -eq 'Client Credentials') { - throw ('This function is not available when using client_credentials authentication. If this is unexpected please report this to api@ninjarmm.com.') - exit 1 - } $CommandName = $MyInvocation.InvocationName $Parameters = (Get-Command -Name $CommandName).Parameters $QSCollection = New-NinjaOneQuery -CommandName $CommandName -Parameters $Parameters diff --git a/Source/Public/Get/Ticketing/Get-NinjaOneTicketBoards.ps1 b/Source/Public/Get/Ticketing/Get-NinjaOneTicketBoards.ps1 index fc91a6d..8a9b71f 100644 --- a/Source/Public/Get/Ticketing/Get-NinjaOneTicketBoards.ps1 +++ b/Source/Public/Get/Ticketing/Get-NinjaOneTicketBoards.ps1 @@ -25,10 +25,6 @@ function Get-NinjaOneTicketBoards { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Uses dynamic parameter parsing.')] Param() begin { - if ($Script:NRAPIConnectionInformation.AuthMode -eq 'Client Credentials') { - throw ('This function is not available when using client_credentials authentication. If this is unexpected please report this to api@ninjarmm.com.') - exit 1 - } $CommandName = $MyInvocation.InvocationName $Parameters = (Get-Command -Name $CommandName).Parameters $QSCollection = New-NinjaOneQuery -CommandName $CommandName -Parameters $Parameters diff --git a/Source/Public/Get/Ticketing/Get-NinjaOneTicketForms.ps1 b/Source/Public/Get/Ticketing/Get-NinjaOneTicketForms.ps1 index 3f7ad16..48218b0 100644 --- a/Source/Public/Get/Ticketing/Get-NinjaOneTicketForms.ps1 +++ b/Source/Public/Get/Ticketing/Get-NinjaOneTicketForms.ps1 @@ -36,10 +36,6 @@ function Get-NinjaOneTicketForms { [Int]$ticketFormId ) begin { - if ($Script:NRAPIConnectionInformation.AuthMode -eq 'Client Credentials') { - throw ('This function is not available when using client_credentials authentication. If this is unexpected please report this to api@ninjarmm.com.') - exit 1 - } $CommandName = $MyInvocation.InvocationName $Parameters = (Get-Command -Name $CommandName).Parameters $QSCollection = New-NinjaOneQuery -CommandName $CommandName -Parameters $Parameters diff --git a/Source/Public/Get/Ticketing/Get-NinjaOneTicketLogEntries.ps1 b/Source/Public/Get/Ticketing/Get-NinjaOneTicketLogEntries.ps1 index d3f9e40..f9d4238 100644 --- a/Source/Public/Get/Ticketing/Get-NinjaOneTicketLogEntries.ps1 +++ b/Source/Public/Get/Ticketing/Get-NinjaOneTicketLogEntries.ps1 @@ -37,10 +37,6 @@ function Get-NinjaOneTicketLogEntries { [String]$type ) begin { - if ($Script:NRAPIConnectionInformation.AuthMode -eq 'Client Credentials') { - throw ('This function is not available when using client_credentials authentication. If this is unexpected please report this to api@ninjarmm.com.') - exit 1 - } $CommandName = $MyInvocation.InvocationName $Parameters = (Get-Command -Name $CommandName).Parameters # Workaround to prevent the query string processor from adding an 'ticketid=' parameter by removing it from the set parameters. diff --git a/Source/Public/Get/Ticketing/Get-NinjaOneTickets.ps1 b/Source/Public/Get/Ticketing/Get-NinjaOneTickets.ps1 index fed4730..cdcad6a 100644 --- a/Source/Public/Get/Ticketing/Get-NinjaOneTickets.ps1 +++ b/Source/Public/Get/Ticketing/Get-NinjaOneTickets.ps1 @@ -55,13 +55,12 @@ function Get-NinjaOneTickets { [Int]$pageSize, # The search criteria to apply to the request. [Parameter(ParameterSetName = 'Board', Position = 5)] - [String]$searchCriteria + [String]$searchCriteria, + # Include the metadata in the response. + [Parameter(ParameterSetName = 'Board', Position = 6)] + [Switch]$includeMetadata ) begin { - if ($Script:NRAPIConnectionInformation.AuthMode -eq 'Client Credentials') { - throw ('This function is not available when using client_credentials authentication. If this is unexpected please report this to api@ninjarmm.com.') - exit 1 - } } process { try { @@ -70,7 +69,7 @@ function Get-NinjaOneTickets { $Resource = ('v2/ticketing/ticket/{0}' -f $ticketId) $Method = 'GET' } else { - Write-Verbouse ('Getting tickets for board with id {0}.' -f $boardId) + Write-Verbose ('Getting tickets for board with id {0}.' -f $boardId) $Resource = ('v2/ticketing/trigger/board/{0}/run' -f $boardId) $Method = 'POST' } @@ -80,7 +79,7 @@ function Get-NinjaOneTickets { if ($QSCollection) { $RequestParams.QSCollection = $QSCollection } - if ($sort -or $filters -or $lastCursorId -or $searchCriteria) { + if ($PSCmdlet.ParameterSetName -eq 'Board') { $RequestParams.Body = [hashtable]@{} } if ($sort) { @@ -101,10 +100,12 @@ function Get-NinjaOneTickets { $Tickets = New-NinjaOnePOSTRequest @RequestParams } if ($Tickets) { - if ($includeMetadata) { + if ($includeMetadata -or $PSCmdlet.ParameterSetName -ne 'Board') { + Write-Verbose 'Returning full response.' return $Tickets } else { # Return just the `data` property which lists the tickets. + Write-Verbose 'Returning just the ticket data.' return $Tickets.data } } else { diff --git a/build.ps1 b/build.ps1 index a697831..81f8ba7 100644 --- a/build.ps1 +++ b/build.ps1 @@ -224,7 +224,7 @@ This page has been generated from the {0} PowerShell module source. To make chan } # Task: Build the PowerShell Module function Build { - Build-Module -Path (Resolve-Path -Path ('{0}\*\build.psd1' -f $PSScriptRoot)) -Semver $SemVer.ToString() + Build-Module -Path '.\Source' -SemVer $SemVer.ToString() } # Task: Copy PowerShell Module files to output folder for release on PSGallery function CopyModuleFiles { diff --git a/test.ps1 b/test.ps1 index 1866e8c..471f581 100644 --- a/test.ps1 +++ b/test.ps1 @@ -6,7 +6,7 @@ param( [switch]$IncludeVSCodeMarker ) Push-Location $PSScriptRoot -$ModuleName = Get-ChildItem -Path '.\Source' -Filter '*.psd1' | Select-Object -ExpandProperty BaseName +$ModuleName = Get-ChildItem -Path '.\Source\*' -Filter '*.psd1' -Exclude 'build.psd1' | Select-Object -ExpandProperty BaseName # Disable default parameters during testing, just in case $PSDefaultParameterValues += @{} $PSDefaultParameterValues['Disabled'] = $true