Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Finding Path of file and copy it to the right path

$
0
0

I'm trying to figure out how to determine the full path of files from a compare-object cmdlet.. Here's some of my code:

[xml]$LHotFixes=Get-Content"E:\WSU_REPO\Hotfixes1.xml"
#This command parses an XML file and lists the value of "file" in it.
$LCompareXmlFile=$LHotFixes.SelectNodes("//HF") | Select -ExpandProperty File
#Compare file values from remote and local xml files
$CompareXmlKBDiff= (Compare-object-Ref$RCompareXmlFile-Diff$LCompareXmlFile-SyncWindow 25)

A file value looks like this: File="KB974571.MSU" 

The problem with the compare statement is that it lists all the files, but I don't know the path of the file so I can copy it into the right folder. For example the files will be in "c:\temp\x86" or "c:\temp\x64". How do I go about finding the file path, and then copying them into the right folder?

I do have an md5 hash of every file on the remote and local system, but not sure how to use this data to copy it to the right folder. Here's one of the commands to get hash of the local files:

$LocalHashx64= (dir "E:\WSU_REPO\2008\x64"-Recurse | Where-Object {!$_.psiscontainer} | Get-Hash-StringEncoding ASCII -Algorithm MD5)

Thanks for your help and suggestions. If you need more info, context or script examples please let me know. Thank you!


Viewing all articles
Browse latest Browse all 8583

Trending Articles