Comparing two folders.

I recently was backing up my data and the backup device had lots of space so i turned up copying folders from multiple directories to the disc. But now was at loss when it came to deleting data from my hard drive. So wrote this little script. Thanks to Ying lin for showing the contains operator in powershell.

#usage = .\Compare-Items-in-two-directories.ps1 -path1 “e:\to write\dataondisk” -path2 “f:\dataoncd”

param([String] $path1,$path2)

$Diskdir = @()

$CDdir = @()

Get-childitem -Path$path1-recurse | %{$Diskdir=$Diskdir+$}

$Diskdir.count Get-childitem -Path$path2-recurse | %{$CDdir=$CDdir+$} $CDdir.count

$arraymatch= @()

$arraynotmatch= @()

foreach ($Itemin$Diskdir)






else      {







About parag waghmare

I am working on the Windows technologies for a long time now. Primarily working as a Service Engineer on System Center products. Right now on System Center 2012 and Windows Server 2012. I have worked extensively on MOM 2005 to SCOM 2007 migrations and SCOM 2007 to SCOM 2012 migrations.
This entry was posted in Powershell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s