スクリプトは一目瞭然ですが、どのように機能させるのかわかりません。$ComputerPath
変数を関数とそのスクリプトセットに渡す方法を理解したい$ComputerPath
Function CheckPath {
While (!$args[0]) {
Write-Host "`nVariable Undefined"
$Args[0] = Read-Host "Enter Valid Path"
}
while (!(test-path $Args[0])) {
Write-Host "Unable To Location Files, Please Check Again."
$args[0] = Read-Host "Enter Valid Path"
}
}
$ComputersPath = "missingfile.txt"
$ComputersPath
CheckPath $ComputersPath
$ComputersPath
私の結果
PS Z:\Powershell Scripting\Test Lab> .\TestFunction.ps1
missingfile.txt
Unable To Location Files, Please Check Again.
Enter Valid Path: log.txt
missingfile.txt
PS Z:\Powershell Scripting\Test Lab>