locked
Export-CSV Issues with data RRS feed

  • Question

  • I'm running a script to remotely grad installed software from the registry. (I like this method over "Get-WmiObject win32_Product" and other methods.) I really want the computername to be the first column in the CSV. The following works, but everything I've tried to place the computername in the first column of the csv has failed:

    Function CheckPing {$result = Test-Connection -count 1 -computer $entry -quiet
    IF ($result -eq "True") {RunBody}
    ELSE
    {echo $entry >> C:\temp\offline.txt}
    }

    Function RunBody
    {
    Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object {Get-ItemProperty $_.pspath} |
    Where-Object {$_.DisplayName -and !$_.SystemComponent -and !$_.ReleaseType -and !$_.ParentKeyName -and ($_.UninstallString -or $_.NoRemove)} |
    Export-CSV c:\temp\SoftwareINVviaREG_$((Get-Date).ToString('MM-dd-yyyy')).csv -append -force -NoTypeInformation
    }
    cls

    Write-Host "Scanning Systems for Inventory Data....." -ForegroundColor Green
    $computers = get-content c:\temp\systems.txt
    ForEach ($entry in $computers){CheckPing}

    I just knew "$entry | Export-CSV c:\temp\SoftwareINVviaREG_$((Get-Date).ToString('MM-dd-yyyy')).csv -append -force -NoTypeInformation" would add the computername, but I get "PSPath PSParentPath PSChildName PSDrive PSProvider ReadCount Length
    C:\temp\systems.txt C:\temp systems.txt C Microsoft.PowerShell.Core\FileSystem 3 6"! Please help! :) and thanks

    Tuesday, November 6, 2012 10:52 PM

Answers