Re: Powershell to compare to Directory Trees?
- From: AreWeThereYet <AreWeThereYet@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 25 Nov 2007 16:10:02 -0800
Thanks, this is proving very helpful! and gives me a better idea of how
PowerShell Scripting works.
One question I CANNOT find the answer to:
In *INX one can hit <Ctrl+D> or <Ctrl+Z> to suspend a process usually as a
prelude to sending it to the background or killing the process. How do I do
this in PowerShell?
"Shay Levi" wrote:
.
Here's a sample Powershell script
$source="C:\Backup"
$destination="D:\temp\backup"
get-childitem -path $source -recurse | where {!$_.PSIsContainer} |
foreach {
$path=$destination+$_.fullname.remove(0,$source.length)
# test if the file already exist on destination direcotry
if(test-path $path -pathtype leaf){
# if the file sizes are not equal copy the file again - overwrite
if($_.length -ne (get-childitem $path).length){
write-host "files $($_.name) length dont match"
copy-item $_.fullname -destination $path
}
} else {
write-host "the file $($_.name) doesn't exist, copy to destination"
copy-item $_.fullname -destination $path -force
}
}
--
Shay Levi
------------------------------------------------------------------------
Shay Levi's Profile: http://forums.techarena.in/member.php?userid=35878
View this thread: http://forums.techarena.in/showthread.php?t=859035
http://forums.techarena.in
- Follow-Ups:
- Re: Powershell to compare to Directory Trees?
- From: Shay Levi
- Re: Powershell to compare to Directory Trees?
- References:
- Re: Powershell to compare to Directory Trees?
- From: Shay Levi
- Re: Powershell to compare to Directory Trees?
- Prev by Date: Re: blocking ping reply
- Next by Date: Re: Recovering files from a slave drive
- Previous by thread: Re: Powershell to compare to Directory Trees?
- Next by thread: Re: Powershell to compare to Directory Trees?
- Index(es):