Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DeviceConfiguration_Import_FromJSON.ps1 #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions DeviceConfiguration/DeviceConfiguration_Import_FromJSON.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

####################################################
Expand All @@ -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"