Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

powershell wmi printer and pnp export to csv

$
0
0

hello i am trying to export to csv; all of the devices found on multiple computers using powershell and wmi, when trying to capture either printer data or pnp, i am only able to loop 1 data value to export to my csv. here is a little snippet, right now i am just trying to gather pnp data.

$computers = Get-Content -Path C:\machines.txt
$computers | foreach-object {	
$PrintInfos = get-wmiobject Win32_PnPEntity -cn $_
  ForEach ($PrintInfo in $PrintInfos)
    {		
$props=[ordered]@{ "ComputerName" = $_"DeviceID" = $PrintInfo.Name
    }
}		
new-object PSObject -property $props #
  } | Sort ComputerName | Export-csv C:\Users\Public\outputfile.csv -notypeinformation

Thank you for the help.

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>