【发布时间】:2018-03-13 14:56:25
【问题描述】:
我正在尝试为我的 MDT 部署共享中的所有 WIM 文件生成报告。基本上,我认为需要对找到的所有 WIM 文件执行 ForEach 循环。我有我认为应该工作的东西,但显然,它没有。我还有多远?
$WimPath = "G:\DeploymentShare\Operating Systems"
Get-ChildItem -Path $WimPath -Filter *.wim -Recurse -File | Select-Object -ExpandProperty VersionInfo | Select-Object FileName | ForEach-Object { Get-WindowsImage -ImagePath $_ }
我看到的错误是关于 Get-WindowsImage 命令的参数不正确。
Get-WindowsImage : The parameter is incorrect.
At line:3 char:147
+ ... t-Object FileName | ForEach-Object { Get-WindowsImage -ImagePath $_ }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我认为我的Select-Object 没有像我认为的那样工作,或者我没有在我的Get-WindowsImage 命令中正确使用管道。
【问题讨论】:
-
试试
Get-ChildItem -Path $WimPath -Filter *.wim -Recurse -File | ForEach-Object { Get-WindowsImage -ImagePath $_.fullname } -
@Brendand62269,干得好!我想知道我是否甚至需要
Select-Object。我想我没有...我如何将您标记为正确回答的人?
标签: powershell foreach powershell-5.0 mdt