나는've tried 바깥쪽에 다음과 같은 경우 문서 나를 실행할 수 있는 또 다른 명령이 성공하면:
Get-WmiObject -Class Win32_Share -ComputerName $Server.name -Credential $credentials -Filter "Description='Default share'" | Foreach-Object {
$Localdrives += $_.Path
그러나 나는 할 수 있't 어떻게 그것을 할 수 있습니다. 이 시도를 만드는 기능을 하지만 난 그러지't 알아내는 방법을 확인하는 경우에는 기능을 성공적으로 완료된다.
도$? 자동 변수:
$share = Get-WmiObject -Class Win32_Share -ComputerName $Server.name -Credential $credentials -Filter "Description='Default share'"
if($?)
{
"command succeeded"
$share | Foreach-Object {...}
}
else
{
"command failed"
}
$?
Contains the execution status of the last operation. It contains
TRUE if the last operation succeeded and FALSE if it failed.
...
$LastExitCode
Contains the exit code of the last Windows-based program that was run.