PowerTip: Use PowerShell to Generate Object with Two Property Types

Doctor Scripto

Dr Scripto

Summary: Use Windows PowerShell to generate an object with two property types.

Hey, Scripting Guy! Question How can I use Windows PowerShell to generate an object with two property types from simply splitting a string?

Hey, Scripting Guy! Answer Use the ConvertFrom-String cmdlet to pipe a string, and then specify the desired property types, for example:

PS C:\>“123 456” | ConvertFrom-String –PropertyType String,Int

 

Doctor Scripto
Dr Scripto

Scripter, PowerShell, vbScript, BAT, CMD

Follow Dr Scripto   

0 comments

    Leave a comment