none
export output to .csv file fro powershell RRS feed

  • Question

  • I have the code which traverse through the zip files and display txt  files .But I need to export to the .csv file .

    Can any one suggest .


        $search  = "txt"
        $zips   = "\\cmciimsdb01\PADWH" 

    #----------------------------------------------------

    Function GetZipFileItems 
        { 
          Param([string]$zip) 

          $split = $split.Split(".")

        $shell   = New-Object -Com Shell.Application 
        $zipItem = $shell.NameSpace($zip) 
        $items   = $zipItem.Items() 

        GetZipFileItemsRecursive $items
        }

        Function GetZipFileItemsRecursive 
        { 
          Param([object]$items) 
          ForEach($item In $items) 
         {
        $strItem = [string]$item.Name 
            If ($strItem -Like "*$search*")
          { 
        Write-Host "The txt files in the zips are : $strItem"   }
         }
        }
        Function GetZipFiles 
        { 
          $zipFiles = Get-ChildItem -Path $zips -Recurse -Filter "*.zip" | % { $_.DirectoryName + "\$_" } 

          ForEach ($zipFile In $zipFiles) 
          { 
            $split = $zipFile.Split("\")[-1] 
            Write-Host "Found zip-file : $split" 
            GetZipFileItems $zipFile 
          } 
        }
        GetZipFiles

    Thursday, July 6, 2017 3:12 PM

All replies

  • ..... .But I need to export to the .csv file .

    You can use the cmdlet Export-CSV.

    BTW: Please format your code as code here in the forum. There is an according option on the edit bar when you create a post.


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Thursday, July 6, 2017 4:03 PM