脚本需要读取参数,如果它大于15退出或小于1退出。遇到“IF”声明的麻烦。继续给我错过括号错误。
$post = Read-Host 'How many folders would you like to create?'
$post
If ($post -gt 15)
{
echo "Error too many arguments"
exit
}
elseif ($post -lt 1)
{
echo "Error: Not enough arguements"
exit
}
$intFolders = $post
$intPad
$i = 1
New-Variable =Name striPrefix -Value "testFolder" -Option constant
do {
if ($i -lt 15)
{$intPad = 0
New-Item -path c:\mytest -name $strPrefix$intPad$i -type directory}
else
{New-Item -path c:\mytest -name $strPrefix$i -type directory}
$i++
}until ($i -eq $intFolders+1)
答案 0 :(得分:4)