The script is self-explanitory but I have no idea how to get it to work. I want to figure out how to pass the variable $ComputerPath to the function and in that script set $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
My Result
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>