How to Format Bullet Points in PowerShell Output?

0
8
Asked By SillyGoose42 On

I'm working on a PowerShell script to gather machine information and copy it to the clipboard for easier logging. I want the output to look nice with bullet points, but I'm having trouble with how PowerShell formats the characters. I know that the ASCII code for a bullet point is 0149, but my script isn't working as expected. Here's my code:

Function Get-ListData {
"2 ListItemOne: $Env:Var1 `
2 ListItemTwo: $Env:Var2 `
2 ListItemThree: $Env:Var3 `
2 ListItemFour: $Env:Var4"| Clip
}

The output I'm getting looks weird:

ListItemOne: Output1
ListItemTwo: Output2
ListItemThree: Output3
ListItemFour: Output4

Can someone help me figure out how to get the bullet points to display correctly?

3 Answers

Answered By TechWhiz101 On

It seems like you're mixing up `clip.exe` and `Set-Clipboard`. You might want to try using `Set-Clipboard` instead to see if that preserves your formatting better. It's worth a shot!

SillyGoose42 -

I hadn't thought of that! I'm not a total newbie, but I still have a lot to learn. I appreciate the advice!

Answered By ScriptGuru89 On

Using `Set-Clipboard` worked for me as well. Also, instead of using escape characters, you could use a single multi-line string:

Function Get-ListData {
@"
2 ListItemOne: $Env:Var1
2 ListItemTwo: $Env:Var2
2 ListItemThree: $Env:Var3
2 ListItemFour: $Env:Var4
"@ | Set-Clipboard
}

SillyGoose42 -

That did the trick! Thanks a ton!!!

Answered By EfficientCoder On

Why not just use PowerShell to gather data and then paste it into a word processor? You can format everything there nicely. Just a thought, but it might save some time!

SillyGoose42 -

That's a good point, but I'm trying to automate the process so users don’t have to handle it manually. Just trying to keep things lazy, you know!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.