Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have loooked for an answer to this question, but cannot find out how to add into an object creating a data-set pair of file name and version, and the related original wsp or cab filename.

I have a script that sends goes through the wsp files in a folder, changes the extension to cab and then outputs to csv, the cab file name & the dlls contained in it to csv. I have been asked to include the dll file version with the dll filename separated by a space (or some other character), e.g. myfirst.dll 1.02.03;mysecond.dll 1.2.0.0 etc paired with the cab file name.

Original script (without file version):

Get-ChildItem C:\WSP\* -Include *.wsp,*.cab | Rename-Item -NewName {$_.basename+".cab"} -PassThru | Foreach {
        $files = (expand -d ($_.fullname)) -match "dll$" | Foreach {($_ -split ": ")[1]}
        New-Object PsObject -Property @{
            CabName = $_.basename
            DllNames = $files -join ";"
        }
    } | Export-Csv C:\WSP\result.csv -NoTypeInformation

Amended script:

Get-ChildItem C:\WSP\* -Include *.wsp,*.cab | Rename-Item -NewName {$_.basename+".cab"} -PassThru | Foreach {
        $files = (expand -d ($_.fullname)) -match "dll$" | Foreach {($_ -split ": ")[1]}
        $allinfo=(New-Object PsObject -Property @{
            CabName = $_.basename
            DllNames = $files -join ";"
        })
        $version=(Get-Command $files) |$_.FileVersionInfo.fileversion
        $allinfo add-member -membertype noteproperty -name Version -value Sversion -join "; "
            } | Export-Csv C:\WSP\result.csv -NoTypeInformation

When run - PS just sits there - I have to type ctrl + C to get it to exit from execution.

Can anyone please advise what I am doing wrong.

Thanks,

Graham

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.