【问题标题】:Get-ChildItem does not Fetch Files when Used a Variable for Drive Letter当使用驱动器号的变量时,Get-ChildItem 不获取文件
【发布时间】:2017-02-17 08:20:33
【问题描述】:

以下代码工作: Get-ChildItem "C:\" -recurse -include *.dll

但是当驱动器被替换为包含字符串的变量时,以下代码不起作用。

$temp = "C:"; Get-ChildItem "$temp" -recurse -include *.dll.

任何线索可能是什么问题??

【问题讨论】:

  • 无法使用发布的代码进行复制。尝试在新的 powershell 会话中只运行这一行。如果它运行,问题是别的。否则可能是 PS 配置文件脚本中的一些损坏的代码。

标签: powershell find powershell-2.0 powershell-3.0 get-childitem


【解决方案1】:

问题已通过以下方式解决: $temp = "C:"; Get-ChildItem $temp -recurse -include *.dll

【讨论】:

    【解决方案2】:

    试试这个:

    $temp = "C:\Program Files"
    $DllDirectory = Get-ChildItem -Path $temp -Recurse -Include *.dll
    $DllDirectory
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-29
      • 1970-01-01
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      相关资源
      最近更新 更多