我想直到做一個PS腳本直到從.csv fil創建多個文件夾。 這是給我一些問題創建多個文件夾,如果不存在
這是我的代碼
$Folders = Import-Csv C:\Scripts\NewFolders\NewFolders.csv
ForEach ($Folder in $Folders)
{
If(!(Test-Path $Folder.Path\$Folder.Folder))
}
New-Item -ItemType Directory -Force -Path $Folder.Path\$Folder.Folder
Write-Host Folder $Folder.Folder created in $Folder.Path ! -ForegroundColor Green
}
Else
{
Write-Host "Folder $Folder.Folder already exists in $Folder.Path !!!" -ForegroundColor Red -BackGroundColor Black
}
}
這是我的錯誤
At C:\Scripts\CreateMultipleFoldersWithCheck.ps1:5 char:45 + If(!(Test-Path $Folder.Path\$Folder.Folder)) + ~ Missing statement block after If (condition). At C:\Scripts\CreateMultipleFoldersWithCheck.ps1:9 char:3 + } + ~ Unexpected token '}' in expression or statement. At C:\Scripts\CreateMultipleFoldersWithCheck.ps1:14 char:1 + } + ~ Unexpected token '}' in expression or statement. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : MissingStatementBlock
我缺少什麼?
後立即您如果語句您有一個結束}而不是開口{ – Eilidh
更改不正確}到{對於初學者:) – Eilidh