【问题标题】:Powershell Windows 2003 Wildcard not workingPowershell Windows 2003 通配符不起作用
【发布时间】:2012-06-16 04:24:21
【问题描述】:

我在 Windows 2003 和 Windows 2008 中都运行 Powershell,并且两者都在运行 2.0,但在 Windows 2003 中似乎不接受通配符(或者至少不以相同的方式做出反应)。例如:

((get-counter -counter '\process(w3*)\id process').CounterSamples)

在 Windows 2008 中运行良好,但在 Windows 2003 中失败。

((get-counter -counter '\process(w3wp)\id process').CounterSamples)

在 Windows 2003 中运行良好。

如何在 Windows 2003 中根据通配符进行过滤?

【问题讨论】:

    标签: powershell windows-server-2003 wildcard


    【解决方案1】:

    您好,我遇到了这样的问题,这似乎是由于 windows server 2003 和 2008 工作方式之间的差异而不是 powershell 本身造成的,所以我所做的是编写一个代码块来检测我使用的 windows server 的版本正在运行,然后更改我要执行的代码。您可以使用下面的代码或将其放入 switch 语句中。

    $WindowsVesrion = Get-WmiObject win32_operatingSystem
    
    IF ($WindowsVesrion.Version -gt 6.0)
        {
        ((get-counter -counter '\process(w3*)\id process').CounterSamples)
        }
    ELSE {
         ((get-counter -counter '\process(w3wp)\id process').CounterSamples)
         }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-05
      • 2014-08-01
      相关资源
      最近更新 更多