|
5 | 5 | - [`Import-Module` issues](#import-module-issues) |
6 | 6 | - [Tool uninstall issues](#tool-uninstall-issues) |
7 | 7 | - [`Initialize-NatNetwork` issues](#initialize-natnetwork-issues) |
8 | | -- [`'Test-Json' is not recognized as the name of a cmdlet`](#test-json-is-not-recognized-as-the-name-of-a-cmdlet) |
9 | 8 |
|
10 | 9 | ## `Import-Module` issues |
11 | 10 |
|
@@ -108,42 +107,3 @@ Import-Module HNS |
108 | 107 | > [!CAUTION] |
109 | 108 | > **We do not recommend** using the [_third-party_ HNS module](https://www.powershellgallery.com/packages/HNS/0.2.4) available in the PowerShell Gallery. This module is **NOT** maintained and signed by Microsoft and may not be up-to-date with the latest changes in the HNS module. |
110 | 109 | > _Microsoft does **NOT** take any responsibility for issues that may arise from installing and/or execution of commands in any third-party modules/scripts. Install the _third-party_ HNS module at your own risk!_ |
111 | | -
|
112 | | -## `'Test-Json' is not recognized as the name of a cmdlet` |
113 | | - |
114 | | -This error occurs because the `Test-Json` cmdlet was introduced in **PowerShell 6.1** and is not available in **Windows PowerShell 5.1** or earlier. To maintain compatibility, a custom implementation of `Test-Json` is provided for environments where the native cmdlet is unavailable. |
115 | | - |
116 | | -To enable this compatibility, you must ensure that the `Newtonsoft.Json` and `Newtonsoft.Json.Schema` assemblies are loaded in your PowerShell session. You can do this in one of two ways: |
117 | | - |
118 | | -**Option 1 – Use the loader script** |
119 | | - |
120 | | -Use the `Load-NewtonsoftDlls` script to automatically download and load the required assemblies: |
121 | | - |
122 | | -```powershell |
123 | | -.\build\hacks\Load-NewtonsoftDlls.ps1 |
124 | | -``` |
125 | | - |
126 | | -**Option 2 – Load the assemblies manually** |
127 | | - |
128 | | -1. **Download the NuGet package**: |
129 | | - |
130 | | - ```powershell |
131 | | - $newtonsoftDir = \"$env:USERPROFILE\Documents\PowerShell\Modules\Newtonsoft.Json\" |
132 | | - nuget.exe install Newtonsoft.Json.Schema -OutputDirectory $newtonsoftDir -Framework \"net45\" -ExcludeVersion |
133 | | - ``` |
134 | | - |
135 | | -2. **Load the assemblies**: |
136 | | - |
137 | | - ```powershell |
138 | | - $jsondllPath = \"$newtonsoftDir\\Newtonsoft.Json\\lib\\net45\\Newtonsoft.Json.dll\" |
139 | | - [Reflection.Assembly]::LoadFile($jsondllPath) | Out-Null |
140 | | -
|
141 | | - $schemadllPath = \"$newtonsoftDir\\Newtonsoft.Json.Schema\\lib\\net45\\Newtonsoft.Json.Schema.dll\" |
142 | | - [Reflection.Assembly]::LoadFile($schemadllPath) | Out-Null |
143 | | - ``` |
144 | | - |
145 | | -### Reference |
146 | | - |
147 | | -- [Test-Json](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/test-json?view=powershell-7.4) |
148 | | -- [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json#supportedframeworks-body-tab) |
149 | | -- [Differences between Windows PowerShell 5.1 and PowerShell 7.x](https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.5#new-test-json-cmdlet) |
0 commit comments