看代码符号$?搞不清楚是什么?

 

看代码.

$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.

 

Reference

==================

about_Automatic_Variables

https://technet.microsoft.com/en-us/library/hh847768.aspx

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-03-05
  • 2021-12-05
  • 2021-12-22
  • 2021-11-23
猜你喜欢
  • 2021-06-09
  • 2021-11-29
  • 2022-02-09
  • 2022-12-23
  • 2021-11-07
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案