DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

Create a Custom Structure in PowerShell

Learn the straightforward [pscustomobject] pattern for PowerShell records, when to use an ordered hashtable or class, and which runtime details affect behavior.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To create a simple PowerShell record with named properties, cast a hashtable literal to [pscustomobject]:

$person = [pscustomobject]@{
    Name = 'Ada'
    Role = 'Engineer'
    Active = $true
}

$person.Name
$person | Get-Member

Use this pattern for an ad hoc object you can access with dot notation and pass through the pipeline. If you need a dictionary whose keys stay in insertion order, use [ordered]@{} instead; if you need a reusable named type, consider a class. The exact behavior of version-sensitive details depends on the PowerShell runtime you use.

How to create a PowerShell object with properties

A hashtable literal supplies the property names and values; the direct cast turns it into a custom object. Read a property with dot notation, and inspect the object’s members with Get-Member.

$person = [pscustomobject]@{
    Name = 'Ada'
    Role = 'Engineer'
    Active = $true
}

$person.Name
$person | Get-Member

This is Microsoft’s documented simple pattern for creating a custom object. Microsoft Learn: about_PSCustomObject

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

How to create a collection of custom objects

Put one custom object per item in an array. Each pipeline item then has its own properties, which downstream commands can select or process:

$people = @(
    [pscustomobject]@{ Name = 'Ada'; Role = 'Engineer' }
    [pscustomobject]@{ Name = 'Grace'; Role = 'Mathematician' }
)

$people | Select-Object Name, Role

Select-Object here projects the requested properties for output; it does not change the purpose of the original objects.

Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Choose the structure that matches the job

Choice Best for Access and ordering
[pscustomobject]@{} A one-off record with named properties Use property access such as $person.Name. A direct cast of a hashtable literal preserves its literal order.
[ordered]@{} A key-value dictionary where insertion order matters Access dictionary keys; keys remain in insertion order.
Add-Member or Select-Object Adding members to, or projecting properties from, existing data Useful for shaping objects created elsewhere rather than declaring the simplest new record.
A class A reusable named type, potentially with type-defined behavior Defines a type for cases where a one-off custom object is not enough.

Microsoft’s object-creation overview also describes creating objects from sources such as CSV or JSON, as well as approaches including Add-Type, New-Module, and .NET object construction. These are alternatives for particular needs, not requirements for every custom record. Microsoft Learn: about_Object_Creation

When to use an ordered hashtable

A hashtable is a key-value dictionary. To make an ordered dictionary, use the [ordered] accelerator:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
$settings = [ordered]@{
    First = 1
    Second = 2
}

The resulting OrderedDictionary keeps keys in insertion order. This is a dictionary, not the same choice as a custom object when you want to work primarily with object properties. Microsoft documents [ordered] in its about_Hash_Tables reference.

Preserve property order when converting to a custom object

PowerShell objects keep members in the order they were added. If the output member order matters, cast the hashtable literal directly, as in [pscustomobject]@{ First = 1; Second = 2 }. Do not assume the same order when converting a normal hashtable stored in a variable, or a parenthesized hashtable; that conversion does not guarantee the literal’s order. See Microsoft’s about_PSCustomObject documentation.

Rank #4
YOTUO 500GB External Hard Drive, Portable Storage Expansion HDD, USB 3.0 & USB-C for PC, Mac, Desktop, Laptop, Smartphone, PS4, Xbox One, Xbox 360, Office & Game Black
  • 【Versatile Storage Expansion – For Gaming, Work & Everyday Use】 Running out of space on your PS5 or Xbox Series X/S? This external hard drive lets you store and play PS4 / Xbox One games directly, instantly freeing up your console’s internal storage for next‑gen titles. At the same time, it handles work file backups, media libraries, and cross‑device data transfers with ease. One drive, all your needs. *(Note: PS5 / Xbox Series X|S games cannot be run or stored directly from the external hard drive. However, by offloading your PS4 / Xbox One games, you can free up valuable space for newer titles.)*
  • 【Patented Silicone Sleeve – Data Protection You Can Count On】 Worried about drops? We’ve got you covered. The patented built‑in silicone sleeve acts like a shock‑absorbing armor, cushioning your drive against bumps and falls. Whether it’s important work documents, precious family photos, or hard‑earned game saves, your data deserves this level of protection.
  • 【Plug & Play, Compatible with Computers & Consoles】 No complicated setup—just plug in and go. Works seamlessly with Windows, Mac, and Linux computers, as well as PS4, PS5, Xbox One, and Xbox Series X/S. Process files at the office, back up data at home, or enjoy gaming in your downtime—one drive handles all your devices, simply and hassle‑free.
  • 【USB 3.0 Ultra‑Fast Transfer – No More Waiting】 Tired of watching progress bars crawl? With USB 3.0 speeds up to 5Gbps, large files transfer in seconds. Whether you’re moving work documents, transferring hundreds of gigs of games, or backing up a year’s worth of photos, you get more done in less time.
  • 【Sleek, Lightweight, and Ready to Go】 Weighing just 0.16 kg—lighter than a can of soda—this compact drive features a stylish mirror‑and‑frosted finish. Toss it in your bag and go, whether you’re heading to the office, visiting a friend for a gaming session, or giving a presentation on the road.

When to shape an existing object instead

Use Add-Member when you need to attach a member to an object you already have. Use Select-Object to select properties or create calculated output properties. These tools are suited to adapting existing data; for a new ad hoc record, the direct [pscustomobject] literal is simpler. Microsoft Learn: about_Object_Creation

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a class is the better fit

Use a class when your task calls for a reusable, named type definition and possibly behavior defined by that type. A class is more structure than a one-off record needs. Microsoft lists class definitions among PowerShell’s object-creation methods in its object-creation overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
WD 2TB Elements Portable External Hard Drive for Windows, USB 3.2 Gen 1/USB 3.0 for PC & Mac, Plug and Play Ready - WDBU6Y0020BBK-WESN
  • High capacity in a small enclosure – The small, lightweight design offers up to 6TB* capacity, making WD Elements portable hard drives the ideal companion for consumers on the go.
  • Plug-and-play expandability
  • Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
  • SuperSpeed USB 3.2 Gen 1 (5Gbps)

PowerShell version details to know

  • Microsoft documents [pscustomobject] and [ordered] as available since PowerShell 3.0. Older runtimes may therefore require a different approach.
  • The documented Count and Length behavior for a hashtable cast to [pscustomobject] differs by runtime: in Windows PowerShell, accessing those members returns $null; PowerShell 6 and later report 1.
  • Do not use an individual record’s Count or Length as a way to count records. For a collection, count the collection itself and verify behavior in the target runtime.

For the compatibility details, see about_PSCustomObject and about_Hash_Tables.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$229.99
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
SaleBestseller No. 5

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.