Skip to content

Instantly share code, notes, and snippets.

@chelnak
Last active July 26, 2016 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelnak/ead612feefe33f059552db4a2cf48a9c to your computer and use it in GitHub Desktop.
Save chelnak/ead612feefe33f059552db4a2cf48a9c to your computer and use it in GitHub Desktop.
Rename a custom object and add a default output for the new type
$Object = [PSCustomObject]@{
Id = "1"
Name = "VM01"
Description = "A virtual machine"
Location = "UK"
IPAddress = "10.0.0.1"
}
$Object.PSObject.TypeNames.Insert(0, "Test.Type")
Update-TypeData -TypeName "Test.Type" -DefaultDisplayPropertySet "Id", "Name", "Description" -Force
$Object
# Id Name Description
# -- ---- -----------
# 1 VM01 A virtual machine
# Or run $Object | Select * to see all properties
# Id : 1
# Name : VM01
# Description : A virtual machine
# Location : UK
# IPAddress : 10.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment