PowerShell Logo Small


This is the built-in help made by Microsoft for the command 'Update-TypeData', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.


Updates the extended type data in the session.


Update-TypeData [[-AppendPath] [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]]
[-PrependPath [<String[]>]] [-Confirm] [-WhatIf] [<CommonParameters>]
Update-TypeData [-DefaultDisplayProperty [<String>]] [-DefaultDisplayPropertySet [<String[]>]] [-DefaultKeyPropertySet [<String[]>]] [-Force] [-InformationAction
{SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-InheritPropertySerializationSet [<Boolean>]] [-MemberName
[<String>]] [-MemberType {AliasProperty | CodeProperty | Property | NoteProperty | ScriptProperty | Properties | PropertySet | Method | CodeMethod | ScriptMethod | Methods |
ParameterizedProperty | MemberSet | Event | Dynamic | All}] [-PropertySerializationSet [<String[]>]] [-SecondValue [<Object>]] [-SerializationDepth [<Int32>]]
[-SerializationMethod [<String>]] [-StringSerializationSource [<String>]] [-TargetTypeForDeserialization [<Type>]] [-TypeAdapter [<Type>]] [-TypeConverter [<Type>]] [-Value
[<Object>]] -TypeName <String> [-Confirm] [-WhatIf] [<CommonParameters>]
Update-TypeData [-TypeData] <TypeData[]> [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String]>]] [-Confirm] [-WhatIf] [<CommonParameters>]

Search powershellhelp.space


The Update-TypeData cmdlet updates the extended type data in the session by reloading the Types.ps1xml files into memory and adding new extended type data.

By default, Windows PowerShell loads extended type data as it is needed. Without parameters, Update-TypeData reloads all of the Types.ps1xml files that it has loaded in the
session, including any type files that you added. You can use the parameters of Update-TypeData to add new type files and add and replace extended type data.

The Update-TypeData cmdlet can be used to preload all type data. This feature is particularly useful when you are developing types and want to load those new types for
testing purposes.

Beginning in Windows PowerShell 3.0, you can use Update-TypeData to add and replace extended type data in the session without using a Types.ps1xml file. Type data that is
added dynamically, that is, without a file, is added only to the current session. To add the type data to all sessions, add an Update-TypeData command to your Windows
PowerShell profile. For more information, see about_Profiles (http://go.microsoft.com/fwlink/?LinkID=113729).

Also, beginning in Windows PowerShell 3.0, you can use the Get-TypeData cmdlet to get the extended types in the current session and the Remove-TypeData cmdlet to delete
extended types from the current session.

Exceptions that occur in properties, or from adding properties to an Update-TypeData command, do not report errors to StdErr. This is to suppress exceptions that would occur
in many common types during formatting and outputting. If you are getting .NET Framework properties, you can work around the suppression of exceptions by using method syntax
instead, as shown in the following example:


Note that method syntax can only be used with .NET Framework properties. Properties that are added by running the Update-TypeData cmdlet cannot use method syntax.

For more information about the *types.ps1xml files in Windows PowerShell, see about_Types.ps1xml (http://technet.microsoft.com/library/hh847881.aspx).



Online Version: http://go.microsoft.com/fwlink/p/?linkid=294025




-------------------------- EXAMPLE 1 --------------------------

PS C:\>Update-Typedata

This command updates the extended type configuration from the *.types.ps1xml files that have already been used in the session.

-------------------------- EXAMPLE 2 --------------------------

The first command updates the extended type configuration from the *.types.ps1xml files, processing the TypesA.types.ps1xml and TypesB.types.ps1xml files first.
PS C:\>Update-Typedata -PrependPath TypesA.types.ps1xml, TypesB.types.ps1xml

The second command shows how to update the TypesA.types.ps1xml again, such as you might do if you added or changed a type in the file. You can either repeat the previous
command for the TypesA.types.ps1xml file, or run an Update-Typedata command without parameters, because TypesA.types.ps1xml is already in the type file list for the current
PS C:\>Update-Typedata -PrependPath TypesA.types.ps1xml



This example show how to update the types in a type file multiple times in the same session.

-------------------------- EXAMPLE 3 --------------------------

PS C:\>Update-TypeData -TypeName System.DateTime -MemberType ScriptProperty -MemberName Quarter -Value {if ($this.Month -in @(1,2,3)) {"Q1"} elseif ($this.Month -in
@(4,5,6)) {"Q2"} elseif ($this.Month -in @(7,8,9)) {"Q3"} else {"Q4"} }
PS C:\>(Get-Date).QuarterQ1

This example uses Update-TypeData to add the Quarter script property to System.DateTime objects in the current session, such as those returned by the Get-Date cmdlet.

The Update-TypeData command uses the TypeName parameter to specify the System.DateTime type, the MemberName parameter to specify a name for the new property, the MemberType
property to specify the ScriptProperty type, and the Value parameter to specify the script that determines the annual quarter.

The value of the Value property is a script that calculates the current annual quarter. The script block the $this automatic variable to represent the current instance of
the object and the In operator to determine whether the month value appears in each integer array. For more information about the In operator, see about_Comparison_Operators

The second command gets the new Quarter property of the current date.

-------------------------- EXAMPLE 4 --------------------------

PS C:\>Update-TypeData -TypeName System.DateTime -DefaultDisplayPropertySet DateTime, DayOfYear, Quarter
PS C:\>Get-Date | Format-List

Thursday, March 15, 2012 12:00:00 AM
DayOfYear : 75
Quarter : Q1

This example shows how to set the properties of a type that display in lists by default, that is, when no properties are specified. Because the type data is not specified in
a Types.ps1xml file, it is effective only in the current session.

The first command uses the Update-TypeData cmdlet to set the default list properties for the System.DateTime type. The command uses the TypeName parameter to specify the
type and the DefaultDisplayPropertySet parameter to specify the default properties for a list. The selected properties include the new Quarter script property that was added
in a previous example.

The second command uses the Get-Date cmdlet to get a System.DateTime object that represents the current date. The command uses a pipeline operator (|) to send the DateTime
object to the Format-List cmdlet. Because the Format-List command does not specify the properties to display in the list, Windows PowerShell uses the default values that
were established by the Update-TypeData command.

-------------------------- EXAMPLE 5 --------------------------

PS C:\>Get-Module | Update-TypeData -MemberType ScriptProperty -MemberName SupportsUpdatableHelp -Value {if ($this.HelpInfoUri) {$True} else {$False}}
Get-Module -ListAvailable | Format-Table Name, SupportsUpdatableHelp

Name SupportsUpdatableHelp
---- ---------------------
Microsoft.PowerShell.Diagnostics True
Microsoft.PowerShell.Host True
Microsoft.PowerShell.Management True
Microsoft.PowerShell.Security True
Microsoft.PowerShell.Utility True
Microsoft.WSMan.Management True
PSDiagnostics False
PSScheduledJob True
PSWorkflow True
ServerManager True
TroubleshootingPack False

This example demonstrates that when you pipe an object to Update-TypeData, Update-TypeData adds extended type data for the object type.

This technique is quicker than using the Get-Member cmdlet or the Get-Type method to get the object type. However, if you pipe a collection of objects to Update-TypeData, it
updates the type data of the first object type and then returns an error for all other objects in the collection because the member is already defined on the type.

The first command uses the Get-Module cmdlet to get the PSScheduledJob module. The command pipes the module object to the Update-TypeData cmdlet, which updates the type data
for the System.Management.Automation.PSModuleInfo type and the types derived from it, such as the ModuleInfoGrouping type that Get-Module returns when you use the
ListAvailable parameter in the command.

The Update-TypeData commands adds the SupportsUpdatableHelp script property to all imported modules. The value of the Value parameter is a script that returns $True if the
HelpInfoUri property of the module is populated and $False otherwise.

The second command pipes the module objects from Get-Module to the Format-Table cmdlet, which displays the Name and SupportsUpdatableHelp properties of all modules in a list.