Reading ziparchive files

Topics: Developer Forum, User Forum
Oct 31, 2016 at 2:08 PM
Edited Oct 31, 2016 at 2:09 PM
I created the following code, but it is not actually reading any of the .zip or .prd files as expected, but the other parts are working. Might you help me figure out why it is not actually reading the zip files in the ForEach loop?
#Set variables for subversion paths
$ScriptPath = (Split-Path $myinvocation.MyCommand.path -Parent)
#$Package = $ScriptPath

#Create folder for temporary copy of SVN directory
New-Item C:\MyTemp-type directory -ErrorAction SilentlyContinue -Force
New-Item C:\Results -type directory -ErrorAction SilentlyContinue -Force
Test-Path $profile
New-item –type file –force $profile

#Set variables for subversion paths
$CurrentSVNPath = "http://MySVNPath" 
$TempSVNPath = "C:\MyTemp"
$ResultsFilePath = "C:\Results"

#Download a local copy of the SVN Repository
 # Wait for command to finish before moving forward
#$SVNDownloadJob = Start-Job {SVN Checkout $CurrentSVNPath $TempSVNPath}
$SVNDownloadJob = Start-Job {TortoiseProc.exe /command:update /path:"C:\SVN_Repo" /closeonend:1 | Out-Null} 
Wait-Job $SVNDownloadJob
Receive-Job $SVNDownloadJob

#Find pattern to search for within all files from where this script is run
    #If you do not want to look for the standard pattern uncomment/comment the $Pattern variables
        #$Pattern = Read-Host 'What pattern are you looing for?'
        $Pattern = "Simulate=`"true`""
        $SearchPattern = “Simulate=`”true`””
        $PackageList = Get-ChildItem –Path $ScriptPath –Recurse –filter “*.zip, *.prd”

#Start searching all folders where this script exists for 'Simulate=true'
$k =foreach ($file in Get-ChildItem -Path $ScriptPath -Recurse | Select-String -pattern $Pattern | Select-Object -Unique path) {$file.path}
$k > "$($ResultsFilePath)\SimulateEqualsTrueZipFiles.txt"

Foreach ( $Package in $PackageList) {
Read-Archive -$_.Path -Format Zip | `
   Where-Object { $_.Name -like "*.zip" } | `
      Expand-Archive -PassThru | select-string $SearchPattern | Select-Object -Unique path {$file.path}
      $k > "$($ResultsFilePath)\SimulateEqualsTrueZipFiles.txt"