Matthew Darens
Matthew Darens

Reputation: 129

PowerShell single-line script to multi-line

There have only been a couple of times that I needed to understand PowerShell scripts, but they are usually written in one line. I have searched the internet and found that some people convert their multi-line scripts to single-line. For me, as a newbie in PowerShell, it is hard to read those scripts sometimes.

Is there any way to convert large single-line scripts to multi-line scripts?

Any tools would be appreciated. Thank you.

Upvotes: 0

Views: 926

Answers (1)

srbrills
srbrills

Reputation: 1547

In any language, sometimes people minify their code, scripts, or payloads. Sometimes there are online tools to 'de-minify' code online, although I don't know if there are ones for PowerShell.

If I ever need to minify or de-minify code manually, I like using Sublime for regex searching and multi-line editing.

https://www.sublimetext.com/

You could use a find and replace using regular expressions (regex), and add new-line characters wherever you wanted. If the script has semicolons, you could search for those and replace each of them with a semicolon followed by a new-line character.

Sublime has a free trial, and doesn't require payment when the trial is over.

Upvotes: 1

Related Questions