Why is my code not executed after the "break" when it is outside the loop? What is the solution, please?
Here is my code:
$disk = 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
$disk | ForEach-Object {
if (!(Test-Path "${_}:\"))
{
$ldisk=$_
$ldisk
break;
}
}
$ldisk
Write-Host "test"
Here is the output
PS D:\powershell> d:\powershell\ftpdisk.ps1
A
For me, my output must be:
PS D:\powershell> d:\powershell\ftpdisk.ps1
A
A
test