Powershell v4.0 Windows 7
$dir = Get-Item -Path "C:TestSource" Get-ChildItem -Path "$($dir.FullName)*" -File -Include *.txt,*.inf
$Dir = Get-Item -Path "C:TestSource" $Filter = "*.txt" Get-ChildItem -Path "$($dir.FullName)*" -File -Include $Filter
但是,这不会返回任何对象:
如何为PHP设置全局环境variables
Python与sudo不能访问环境variables
在Windows上的Java和环境variables
$ VARIABLE和$ {VARIABLE}之间有什么区别
如何获取远程主机的环境variables
$Dir = Get-Item -Path "C:TestSource" $Filter = "*.txt,*.inf" Get-ChildItem -Path "$($dir.FullName)*" -File -Include $Filter
有必要将$ Filtervariables构build到数组中,如下所示:
$Dir = Get-Item -Path "C:TestSource" $Filter = @("*.txt","*.inf") Get-ChildItem -Path "$($dir.FullName)*" -File -Include $Filter
Get-ChildItem上的Microsoft页面使我相信可以在Get-ChildItem cmdlet中使用variables。 但是,为什么该cmdlet不会返回对象,除非该variables是一个数组? 由于显式string在第一个例子中工作,第三个例子不应该工作吗?
registry|中的参数扩展有问题 %〜N1
在Windows中永久更改环境variables
使用SYstem包含外部XML实体,同时使用$ ENVvariablesparsingpath
JRE_HOMEvariables缺lesstomcat(win7)
在OSX上安装的新版本的git,但没有被使用。 我怎样才能find它并使用它?
Include的参数总是一个数组 – 在第一个示例中-Include *.txt,*.inf传递一个两元素数组作为过滤器。
在你的第三个例子中,它是一个逗号分隔的字符串。 如果你传递一个数组,它应该可以工作:
$Dir = Get-Item -Path "C:TestSource" $Filter = "*.txt","*.inf" Get-ChildItem -Path "$($dir.FullName)*" -File -Include $Filter
李回答了这个问题。 在第三个示例中,您正试图为-Include参数传递多个值,但是您没有将其格式设置为数组,因此脚本正在查找名称中包含整个字符串模式的文件: *.txt,*.inf
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。