 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use the ConvertFrom-StringData command in PowerShell?\\n
The ConvertFrom-String command converts the String to the Hashtable format as shown below.
Example
PS C:\> "This is string" | ConvertFrom-String
Output
P1 P2 P3 -- -- -- This is string
In the above example, We haven’t specified any header so that the output is separated the delimiter by space P1, P2 and continuous. By default, this command separates the string with a ‘=’ delimiter as shown below.
Example
$stringhash = @" Name = Spooler Starttype = Manual Status = Stopped "@ $stringhash | ConvertFrom-StringData
Output
Name Value ---- ----- Status Stopped Starttype Manual Name Spooler
Another method we can use is by separating string Keys and values with a delimiter parameter. This parameter is only available in the PowerShell core 7.1 version.
Example
$stringhash = @" Name | Spooler Starttype | Manual Status | Stopped "@ ConvertFrom-StringData -StringData $stringhash -Delimiter '|'
We can also use the below method.
PS C:\> $stringhash = "Name = Spooler `n StartType = Manual `n Status = Stopped" PS C:\> ConvertFrom-StringData -StringData $stringhash Name Value ---- ----- Status Stopped Name Spooler StartType Manual
Advertisements
 