From e0948f45fc19981180871e70662bcf27a3bb5f6f Mon Sep 17 00:00:00 2001 From: MBCloudTeck <93949565+MBCloudTeck@users.noreply.github.com> Date: Mon, 22 May 2023 18:42:53 +0100 Subject: [PATCH] Update DeviceConfiguration_Import_FromJSON.ps1 Updated the import path + added a wait at the end. --- .../DeviceConfiguration_Import_FromJSON.ps1 | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/DeviceConfiguration/DeviceConfiguration_Import_FromJSON.ps1 b/DeviceConfiguration/DeviceConfiguration_Import_FromJSON.ps1 index e0c508c..b3e3c46 100644 --- a/DeviceConfiguration/DeviceConfiguration_Import_FromJSON.ps1 +++ b/DeviceConfiguration/DeviceConfiguration_Import_FromJSON.ps1 @@ -311,22 +311,20 @@ $global:authToken = Get-AuthToken -User $User #################################################### -If (Test-Path -Path $FileName -Type Leaf) { - $ImportPath = $FileName -} Else { - $ImportPath = Read-Host -Prompt "Please specify a path to a JSON file to import data from e.g. C:\IntuneOutput\Policies\policy.json" +if ($FileName -ne $null -and $FileName -ne "") { + $ImportPath = $FileName +} else { + $ImportPath = Read-Host -Prompt "Please specify a path to the JSON file to import data from (e.g., C:\IntuneOutput\Policies\policy.json)" } # Replacing quotes for Test-Path -$ImportPath = $ImportPath.replace('"','') - -if(!(Test-Path "$ImportPath")){ - -Write-Host "Import Path for JSON file doesn't exist..." -ForegroundColor Red -Write-Host "Script can't continue..." -ForegroundColor Red -Write-Host -break +$ImportPath = $ImportPath.Replace('"','') +if(!(Test-Path -Path $ImportPath -Type Leaf)){ + Write-Host "Import Path for JSON file doesn't exist..." -ForegroundColor Red + Write-Host "Script can't continue..." -ForegroundColor Red + Write-Host + break } #################################################### @@ -347,3 +345,5 @@ $JSON_Output write-host Write-Host "Adding Device Configuration Policy '$DisplayName'" -ForegroundColor Yellow Add-DeviceConfigurationPolicy -JSON $JSON_Output + +Read-Host -Prompt "Press Enter to exit"