[ad_1]
I am trying to get the PID/VID from the a usb device though a powershell script. The issue I keep running into, is either the output file not having the full string (gets cut off with a …) or, a formatting error if I do “ft -Auto” then I get:
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
Microsoft.PowerShell.Commands.Internal.Format.GroupStartData
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
Microsoft.PowerShell.Commands.Internal.Format.GroupEndData
Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
I have tried using Add-Content, as well as Out-File but I want to have multiple commands to output to one single file, so that’s also part of the issue.
Here is what I have in my script:
$PrinterList = Get-Content C:\Users\$env:UserName\Desktop\Devices\printerlist.txt
Get-PnpDevice -PresentOnly -FriendlyName $PrinterList | Format-Table -AutoSize | Out-File -FilePath C:\Users\$env:UserName\Desktop\Devices\test.txt
I simply put the friendly name in the printerlist.txt file, for it to search for those devices.
What DOES work, is:
Add-Content -Path C:\Users\$env:UserName\Desktop\Devices\output.txt -Value (Get-PnpDevice -PresentOnly -FriendlyName $PrinterList) -PassThru
However, that cuts off with the … in the text file. Any idea how I can do this? I want to have multiple of these commands to output to one single file, like a log/progress report.
Any help would be greatly appreciated. Thanks!
[ad_2]