Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 3668
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 2, 20222022-06-02T22:30:46+00:00 2022-06-02T22:30:46+00:00

powershell – How do I output data from a script into a text file?

  • 0

[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]

  • 0 0 Answers
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 8087 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1871 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1957 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.