I believe this is a simple question, but I can't wrap my head around it. I want to do diagnostic commands in command shell on Windows. Like this:
$cmd = "ipconfig >> c:\test.txt"
$message = Invoke-Expression($cmd)
[String]$message = Get-Content c:\topsecret\testme.txt
Then I want to be able to read the file and keep the formatting and lastly publish it to pastebin via their API. I've tried, but I seem to lose the formatting no matter what I do. Is this possible to do?