PowerShell Scripts, Tips, Expert Advices, Forums, and Resources

image rotation

Welcome to PowerShell.com, the educational and community site for Windows PowerShell People. Get a quick overview.

Latest Scripts

10-21-2014 - $OSVersionInfo
10-19-2014 - Get-RawPEHeader
10-16-2014 - Get-CPUInfo

Latest Announcements/Events

10-21-2014 - Get High Quality Real And fake Passports,Driver’s...
10-15-2014 - Class Dismissed
10-12-2014 - The Case for PowerShell

As a Powershell.com member you will have access to:

  • Daily PowerShell tips written by Microsoft MVPs and other leading Windows PowerShell experts
  • Free Windows PowerShell advice and training provided by Microsoft MVPs and other leading Windows PowerShell experts
  • Access to leading Windows PowerShell blogs
  • A free ebook, Mastering PowerShell, written by Microsoft MVP Dr. Tobias Weltner
PowerTip of the Day

Creating New Objects

PowerShell 3 and later

Here is a simple, yet effective, way of creating new custom objects:

$object = [PSCustomObject]@{
  Name = 'Weltner'
  ID = 123
  Active = $true
} 

This will produce full-blown PowerShell objects with preset property values:

PS> $object 

Name                                                ID                    Active
----                                                --                    ------
Weltner                                            123                     True



PS> $object.Name
Weltner

PS> $object.Active
True

PS>  

Twitter This Tip! ReTweet this Tip!

Copyright 2012 PowerShell.com. All rights reserved.