If (-not(test-path $FolderPath)){
New-Item -type directory -Path $FolderPath
}
Check if a folder path exists using the Test-Path and if it doesn’t create the folder using New-Item
PS C:\> $FolderPath = "C:\PSScripts" >> If (-not(test-path $FolderPath)){ >> New-Item -type directory -Path $FolderPath >> }