从Powershell Get-ChildItem结果中排除文件

时间:2018-09-18 08:14:18

标签: powershell get-childitem

要从目录中减去每个特定的目录中选择每个AssemblyInfo.cs,我运行一个powershell脚本:

Clear-Host
$SrcDir = "D:\Projects\Lambda\Sources"
Write-Host $SrcDir
cd $SrcDir
$ExcludeXYZCallStrategy = $SrcDir + "\Lambda.XYZ\XYZCallStrategy\Properties\AssemblyInfo.cs"
# 2. Select Files to be updated
Write-Host $ExcludeXYZCallStrategy
# both these syntaxes fail (tried one after the other not together ofc) :
$Assemblyfiles = Get-ChildItem -Path $SrcDir -Recurse -Include AssemblyInfo.cs -Exclude $ExcludeXYZCallStrategy
$Assemblyfiles = Get-ChildItem -Path $SrcDir -Recurse -Include AssemblyInfo.cs -Exclude D:\Projects\Lambda\Sources\Lambda.XYZ\XYZCallStrategy\Properties\AssemblyInfo.cs
Write-Host $Assemblyfiles
Write-Host "Files Count : " $Assemblyfiles.count

我尝试了不同的语法来强制Get-ChildItem排除该文件,但失败了。

我尝试了这些答案,但无济于事:

doc中,我什么都没找到,不能解释为什么不排除该文件。

1 个答案:

答案 0 :(得分:3)

由于只有一个文件,因此您可以使用curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');

Where-Object