PowerShell:如果其他
批处理脚本和powershell 如果此脚本在此脚本上使用其他问题,是否可以使用一种方法来检查是否可以执行其他操作:
PS C:\Users\Amine>
>> Get-PnpDevice -FriendlyName "*LuminonCore IDDCX*" | ft -wrap -autosize Status
Status
------
OK
//after disabling the driver
PS C:\Users\Amine>
>> Get-PnpDevice -FriendlyName "*LuminonCore IDDCX*" | ft -wrap -autosize Status
Status
------
Error
< img src =“ https://i.sstatic.net/wb01l.png” alt =“ powerShell”>
m new to batch scripts and powershell
is there a way to use if else on this script to check if ok do something if error do something else:
PS C:\Users\Amine>
>> Get-PnpDevice -FriendlyName "*LuminonCore IDDCX*" | ft -wrap -autosize Status
Status
------
OK
//after disabling the driver
PS C:\Users\Amine>
>> Get-PnpDevice -FriendlyName "*LuminonCore IDDCX*" | ft -wrap -autosize Status
Status
------
Error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用分组操作员
()
要包装表达式,这样做允许您引用状态>状态 value >返回对象的属性,然后您可以使用
-eq
进行等式评估:上面的示例假设只有一个对象由
返回get-pnpdevice
,但是,由于您使用的是通配符(*
),因此将可能性打开到一个以上的结果,在这种情况下,您需要You can use the Grouping Operator
( )
to wrap the expression, doing so allows you to reference the Value of theStatus
property of the returned object, then you can use-eq
for equality evaluation:The example above assumes there would be only one object returned by
Get-PnpDevice
, however since you're using wildcards (*
), opens up the possibility to more than one result, in which case you would need to loop over each returned object: