我是PowerShell的新手,我正在尝试将没有子文件夹的文件夹复制到另一个文件夹。我在下面提供了我的代码。希望这是有道理的。
$from = 'C:\erp\github\bliss_'
$to = 'C:\erp\websites\bitesize'
$ExcludeFolders = @(".git","DHTMLX","mflasite","nbproject",".gitignore")
Get-ChildItem -Path $from -Recurse -Exclude $ExcludeFolders | Copy-Item $_.fullname -Destination $from -Force -Exclude $ExcludeFolders
答案 0 :(得分:0)
因此-Exclude
符合Path
的条件。您需要输入可识别的模式:
$ExcludeFolders = @(
'*\.git\*'
'*\DHTMLX\*'
'*\mflasite\*'
'*\nbproject\*'
'*\.gitignore'
)
-Exclude <String[]>
Specifies, as a string array, an item or items that this cmdlet excludes in
the operation. The value of this parameter qualifies the Path parameter. Enter
a path element or pattern, such as *.txt. Wildcards are permitted.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false