正在尝试让我的copy-item复制目录中除子文件夹以外的所有内容。我可以在文件夹和文件中排除,但不能排除子文件夹。
我尝试在copy-item中使用get- tried和-exclude,但并没有像我希望的那样排除它们
$exclude = "folder\common"
Get-ChildItem "c:\test" -Directory |
Where-Object{$_.Name -notin $exclude} |
Copy-Item -Destination 'C:\backup' -Recurse -Force
希望通用文件夹存在,但其中的任何内容都不会被复制。
谢谢你的帮助
发布于 2019-09-10 02:52:13
我认为在Get-ChildItem
上使用-exclude
参数是可行的:
$exclude = 'Exclude this folder','Exclude this folder 2','Folder3'
Get-ChildItem -Path "Get these folders" -Exclude $exclude | Copy-Item -Destination "Send folders here"
https://stackoverflow.com/questions/57858059
复制相似问题