Export (0) Print
Expand All
Expand Minimize

Remove-TypeData

Updated: December 3, 2014

Applies To: Windows PowerShell 4.0

Remove-TypeData

Deletes extended types from the current session

Syntax

Parameter Set: RemoveTypeDataSet
Remove-TypeData -TypeData <TypeData> [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: RemoveFileSet
Remove-TypeData -Path <String[]> [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: RemoveTypeSet
Remove-TypeData [-TypeName] <String> [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The Remove-TypeData cmdlet deletes extended type data from the current session. This cmdlet affects only the current session and sessions that are created in the current session.

You can add properties and methods to objects in Windows PowerShell by defining them in Update-TypeData commands and Types.ps1xml files. Remove-TypeData deletes those extended properties and methods from the current session. Remove-TypeData does not delete the Types.ps1xml files or delete any extended type definitions from the Types.ps1xml files. For more information about Types.ps1xml files, see about_Types.ps1xml (http://go.microsoft.com/fwlink/?LinkID=113274).

This cmdlet is introduced in Windows PowerShell 3.0.

Parameters

-Path<String[]>

Deletes from the session extended type data that is defined in the specified files. This parameter is required.

Enter the paths and file names of one or more Types.ps1xml files. Wildcards are not supported. If you omit the path, the default location is the current directory.


Aliases

none

Required?

true

Position?

named

Default Value

Current directory

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TypeData<TypeData>

Delete the specified type data from the session. This parameter is required. Enter a variable that contains TypeData objects (System.Management.Automation.Runspaces.TypeData) or a command that gets TypeData objects, such as a Get-TypeData command. You can also pipe TypeData objects to Remove-TypeData.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-TypeName<String>

Deletes all extended type data for the specified types. For types in the System namespace, enter the short name. Otherwise, the full type name is required. Wildcards are not supported.

You can pipe type names to Remove-TypeData. When you pipe an object to Remove-TypeData, Remove-TypeData gets the type name of the object and removes all type data for the object type.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.Management.Automation.Runspaces.TypeData

    You can pipe TypeData object, such as the ones that the Get-TypeData cmdlet returns, to Remove-TypeData.


  • System.String

    You can pipe the type names to Remove-TypeData. When you pipe an object to Remove-TypeData, Remove-TypeData gets the type name of the object and removes all type data for the object type.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

    This cmdlet does not generate any output.


Notes

  • Remove-TypeData can remove only the extended type data in the current session. It cannot remove extended type data that is on the computer, but has not been added to the current session, such as extended types that are defined in modules that have not been imported into the current session.

Examples

Example 1

This command deletes from the session all type data for the System.Array type, including type data that was added by a Types.ps1xml file and dynamic type data that was added to the session by using the Update-TypeData cmdlet.


PS C:\> Remove-TypeData -TypeName System.Array

Example 2

This command shows the effect of removing extended type data from a session.


 

The first command uses the Get-TypeData cmdlet to get extended type data for the System.DateTime type.

The output shows that a DateTime property has been added to all System.DateTime objects in Windows PowerShell.


PS C:\> Get-TypeData System.DateTime
TypeName        Members
-------- -------
System.DateTime {[DateTime, System.Management.Automation.Runspaces.ScriptPropertyData]}

 

The second command uses the Get-Date cmdlet, which returns a System.DateTime object. The command uses dot notation to get the value of the DateTime property of the System.DateTime object that Get-Date returns.


PS C:\> (Get-Date).DateTime
Friday, January 20, 2012 9:01:00 PM

 

The third command uses the Get-TypeData cmdlet to get all extended type data for the System.DateTime type and the Remove-TypeData cmdlet to delete the extended type data.


PS C:\> Get-TypeData System.DateTime | Remove-TypeData

 

The fourth command shows the effect of deleting the extended type data for the System.DateTime type. The command repeats the second command. However, because the System.DateTime property no longer exists, a command to get its value returns nothing.


PS C:\> (Get-Date).DateTime
PS C:\>

Example 3

This command removes all extended type data for module objects. When you pipe an object to Remove-TypeData, Remove-TypeData gets the name of the object type and removes all type data for all objects of that type.


PS C:\> Get-Module | Remove-TypeData

Example 4

This command uses the Path parameter of the Remove-TypeData cmdlet to remove the extended types that are defined in the Types.ps1xml files that are added by the PSScheduledJob and PSWorkflow modules. This command does not affect dynamic type data that is added by using the Update-TypeData cmdlet. The command succeeds only when the modules have been imported into the current session.

For more information about modules, see about_Modules (http://go.microsoft.com/fwlink/?LinkID=144311).


PS C:\> Remove-TypeData -Path C:\WINDOWS\System32\WindowsPowerShell\v1.0\Modules\PSScheduledJob, C:\WINDOWS\System32\WindowsPowerShell\v1.0\Modules\PSWorkflow\PSWorkflow.types.ps1xml

Example 5

This command removes extended types from a remote session. The command uses the Invoke-Command cmdlet to remove extended type data for all CIM types in the sessions in the $s variable.


PS C:\> Invoke-Command -Session $s {Get-TypeData -TypeName *CIM* | Remove-TypeData} 

Related topics



Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft