Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: The Easy Way to Create a Custom PowerShell Object

$
0
0

Summary: Create a custom Windows PowerShell object with the PSCustomObject type accelerator.

Hey, Scripting Guy! Question What’s the easiest way to create a custom object?

Hey, Scripting Guy! Answer Charlotte Windows PowerShell User group member Brian Wilhite says: One of the easiest ways to create a custom object is to use the PSCustomObject type accelerator.  This “shortcut” will not only create the custom object, but it will arrange the key/value pairs in the order in which they were entered.

$CustomObject = [PSCustomObject]@{a=1;c=3;b=2;d=4}

$CustomObject | Get-Member

 


Viewing all articles
Browse latest Browse all 3333

Trending Articles