gpt4 book ai didi

windows - powershell:get-psdrive 和 where-object

转载 作者:可可西里 更新时间:2023-11-01 11:09:04 34 4
gpt4 key购买 nike

我试图在 Windows 2008 服务器上查找不是“C、E、L、S、T、W”的每个驱动器号。谁能告诉我我逻辑上的错误或我该怎么做?

[char[]]”CELSTW” | Where-Object {!(Get-PSDrive $_ )} 

最佳答案

您从不需要的驱动器号列表 (CELSTW) 开始,并将不存在的驱动器号输出为 psdrive。

您想要的是从所有 PSDrive 的列表开始,然后在与您不想要的相匹配的地方过滤掉它们:

Get-PSDrive | Where-Object { [char[]]"CELSTW" -notcontains $_.Name }

虽然这会给你一堆其他的 PSDrive 类型。您可能还想为 FileSystem 提供程序过滤它:

 Get-PSDrive | Where-Object { [char[]]"CELSTW" -notcontains $_.Name -AND $_.Provider.Name -eq "FileSystem"}

关于windows - powershell:get-psdrive 和 where-object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10558977/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com