【发布时间】:2017-01-22 13:13:00
【问题描述】:
我有一个 PowerShell 脚本,其中包含:
1.$GetP:变量是(获取进程命令)
2.$path和$getfile:是两个变量,用于获取$GetP路径中的所有进程路径。
3.foreach语法:是一种获取$getfile中所有路径的方法(合法版权)。
...
现在我想为每个路径添加 版权 作为新成员到 $GetP 或 Get-Process。
她是我的错误语法:
$GetP = Get-Process
$path = $GetP | select -ExpandProperty Path
$getfile = dir $path -Include *.* -recurse
foreach ($iffile in $getfile)
{
$fname = $iffile.FullName
$vfile = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($fname)
$Copyright = $vfile.LegalCopyright
#$Copyright
}
$FileCopyRight = foreach ($Copyright in $GetP) {
$fpmvar = $vfile.LegalCopyright
$Copyright | Add-Member -NotePropertyName CopyRight -NotePropertyValue $fpmvar -PassThru
}
$GetP | select CopyRight
注意:当您删除$Copyright 中的“#”注释时,它将显示所有版权。
【问题讨论】:
标签: windows powershell