Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Is there a better way to expand a calculated field?

$
0
0

Even if it is faster, it would be bad habit to go back to text parsing like that. PowerShell’s biggest strength is the ability to work with objects, not text.

For example, run it this way, and you’ll see that the text parsing approach looks correct at first, but actually outputs an extra empty string, and includes some unwanted whitespace:

[string](gwmi win32_logicaldisk ) -split '\\\\.+?DeviceID="' -replace ':"' |
ForEach-Object { "'$_'" }

Viewing all articles
Browse latest Browse all 13067

Trending Articles