看代码符号$?搞不清楚是什么?
看代码.
$share = Get-WmiObject -Class Win32_Share -ComputerName $Server.name -Credential $credentials -Filter "Description=‘Default share‘" if($?) { "command succeeded" $share | Foreach-Object {...} } else { "command failed" }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
找到定义如下:
Contains the execution status of the last operation. It contains TRUE if the last operation succeeded and FALSE if it failed.
Reference
==================
about_Automatic_Variables
https://technet.microsoft.com/en-us/library/hh847768.aspx