5

私は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")
4

1 に答える 1

9

問題が何であるかは言わなかったが、ディレクトリ($exclude)が適切に除外されていなかったと思います。代わりに、次のgci行を試してください。

Get-Item -Path H:\program files\symphony\files\* -Exclude Temp, Other, etc, ParsedXML | Get-ChildItem -recurse | ? {!($_.psiscontainer) -AND $_.lastwritetime -gt $Date} | %  { write-host $_.fullname; Copy-Item -path $_.fullname -destination $destDrive}
于 2012-11-13T01:44:04.147 に答える