【问题标题】:How to pass parameter to type option of nslookup in powershell?如何在powershell中将参数传递给nslookup的类型选项?
【发布时间】:2022-09-26 18:17:58
【问题描述】:

在这里,我想在 PowerShell 中使用指定类型的 DNS 记录运行 nslookup。 我通过定义 DNS 记录的类型并使用Foreach 运行nslookup 进行了尝试。

$types = @(\"soa\", \"a\")

Foreach ($type in $types){
    nslookup -type=$type google.com
}

但这似乎不起作用,因为$type 未被识别为参数。

有谁知道如何解决这个问题?

    标签: powershell nslookup


    【解决方案1】:

    用双引号引用整个参数,包括参数名称 - 这将防止 PowerShell 将 -type 解释为托管参数:

    nslookup "-type=$type" google.com
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-23
      • 2017-07-11
      • 1970-01-01
      • 1970-01-01
      • 2019-12-13
      • 2011-08-01
      相关资源
      最近更新 更多