我是新來的powershell,並且在遞歸拷貝期間嘗試排除某些目錄時遇到問題。任何幫助表示讚賞! 在此先感謝。powershell - 在遞歸拷貝期間無法排除文件夾
$Date = Get-Date
$Date = $Date.adddays(-1)
$destPath = "\\destination\test"
$srcPath = "H:\program files\symphony\Save"
$srcPathRemits = 「H:\program files\symphony\files"
$destDrive = "X:"
$User = "user"
$Password = "password"
$exclude = @('H:\program files\symphony\files\Temp\*','H:\program files\symphony\files\Other\*','H:\program files\symphony\files\etc\*','H:\program files\symphony\files\ParsedXML\*')
$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive($destDrive, $destPath, $false, $User, $Password)
gci -recurse -path $srcPathRemits -Exclude $exclude | ? {!($_.psiscontainer) -AND $_.lastwritetime -gt $Date} | % { write-host $_.fullname; Copy-Item -path $_.fullname -destination $destDrive}
$net.RemoveNetworkDrive($destDrive,"true","true")
當你說你遇到了問題,你能更具體嗎?你收到錯誤信息了嗎?它以前如何? – David
請記下你有機會時回答的問題。謝謝。 – David