# Automatically ```PowerShell # Check if $dir exists, and create it if it doesn't if (-not (Test-Path -Path $dir -PathType Container)) {     mkdir $dir } ``` # With user intervention ```PowerShell $Path = Read-Host -Prompt "Please specify a path to export the policy data to e.g. C:\Output" # If the directory path doesn't exist prompt user to create the directory if(!(Test-Path "$Path")){ Write-Host Write-Host "Path '$Path' doesn't exist, do you want to create this directory? Y or N?" -ForegroundColor Yellow $Confirm = read-host if($Confirm -eq "y" -or $Confirm -eq "Y"){ new-item -ItemType Directory -Path "$Path" | Out-Null Write-Host } else { Write-Host "Creation of directory path was cancelled..." -ForegroundColor Red Write-Host break } } ```