question

B14D3-8285 avatar image
0 Votes"
B14D3-8285 asked MotoX80 commented

Save Get-ItemProperty output in csv

I am working on to get usb entries in the registry using

Get-ItemProperty -Path $Path | select FriendlyName | Format-Table | Export-Csv c:\temp\usb1.csv -NoTypeInformation -append.

Using this command and save the result in csv gives me unrecognizable data.

198696-image.png



Can anyone help me to get the info I need, TIA

windows-server-powershell
image.png (11.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered MotoX80 commented

Don't use Format-table.

 Get-Item -path 'C:\windows\*'  | foreach {
     [PSCustomObject]@{ 
         Name = $_.Name;
         Version = $_.LastWriteTime;
     }
 } | Export-Csv c:\temp\WinFiles.csv 
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Removing Format-table works. How about if I want the output just like this?

Machine name and the list of usb

199258-image.png


0 Votes 0 ·
image.png (3.9 KiB)

You haven't shared the rest of your script, so I don't know what variable contains the server name or what the contents of the $path variable are. If you don't share all of the code then I'm left to guess as to what you are doing.

0 Votes 0 ·

Get-ItemProperty -Path $Path | select FriendlyName | Export-Csv c:\temp\usb1.csv -NoTypeInformation -append. This is what I am using. I want to add the computer name,

0 Votes 0 ·
Show more comments
LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered B14D3-8285 commented

Hi B14D3-8285,

I recommend using the Get-PnpDevice powershell command if the devices are currently plugged into your PC. Here’s a guide to its usage:

https://docs.microsoft.com/en-us/powershell/module/pnpdevice/get-pnpdevice?view=windowsserver2022-ps

The following command will produce a list:

Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' }

However, it sounds like you need a historical account of devices? In this case, I believe the information you’re retrieving is all that’s available from the registry.




--If the reply is helpful, please Upvote and Accept as answer--

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yes, I need the the history, thanks.

0 Votes 0 ·