Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Formatting with Get-Content

$
0
0

I am having an issue and perhaps I am going about it all wrong.

I am working on a auditing script and I am trying to get the COMPUTER RSOP to be placed into my audit results. I am trying to make this work

  gpresult /r /SCOPE computer | out-file c:\RSoP.TXT
         $RSoP = [string]::join([environment]::newline, (get-content -path c:\RSoP.TXT))

and it does...when i call to $RSoP, it produces the content. If I look at c:\RSoP.txt, the formatting looks exactly as it does when you run the command from the command prompt.

The problem is that when $RSoP is grabbed with the get-content, the formatting gets stripped out and i get one stream of content that is nearly unusable. Is there a better way to grab the results to maintain formatting? I am a noob and it really seems like it should be easier. If this gets squared away, I can grab alot of other "result from command line" info into my audit report.


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images