I've tried enclosing the following in an if statement so I can execute another command if this succeeds:
Get-WmiObject -Class Win32_Share -ComputerName $Server.name -Credential $credentials -Filter "Description='Default share'" | Foreach-Object {
$Localdrives += $_.Path
but I can't figure out how to do it. I even tried creating a function but I couldn't figure out how to check if the function had successfully completed either.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…