external help file | Module Name | online version | schema |
---|---|---|---|
PSTypeExtensionTools-help.xml |
PSTypeExtensionTools |
2.0.0 |
Export type extensions to a file.
Export-PSTypeExtension -Path <String> [-InputObject <Object>] [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
Export-PSTypeExtension [-TypeName] <String> -MemberName <String[]>
-Path <String> [-Passthru] [-WhatIf] [-Confirm] [<CommonParameters>]
You can use this command in two ways. First, you can export custom type information to a JSON or XML file to import in another PowerShell session using Import-PSTypeExtension. Or you can export the type extensions to a properly formatted ps1xml file, which you can import using Update-TypeData. Export-PSTypeExtension will create the appropriate file based on the extension in the specified path.
If you are exporting to a .ps1xml file, you can use a dynamic parameter called Append. You might want to do this if you have created a property set using New-PSPropertySet, and want to include additional type extensions in the same file.
PS C:\> Export-PSTypeExtension -TypeName system.string -Path c:\work\mystringtypes.json -MemberName Size,IsIPAddress
Export selected type extensions for System.String to a JSON file.
PS C:\> Get-PSTypeExtension system.string | Export-PSTypeExtension -path c:\work\stringtypes.xml
Get all type extensions for System.String and export to an XML file.
PS C:\> Get-PSTypeExtension system.string -members "IsIpAddress","Size","Randomize" | Export-PSTypeExtension -path c:\work\mystring.type.ps1xml -passthru
Directory: C:\work
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 3/9/2021 11:15 AM 858 mystring.type.ps1xml
Export the selected members to a ps1xml file and pass the file object to the pipeline.
PS C:\work> Get-PSTypeExtension system.string |
Export-PSTypeExtension -Path .\all.ps1xml
PS C:\work> Get-PSTypeExtension System.IO.FileInfo |
Export-PSTypeExtension -Path .\all.ps1xml -append
PS C:\work> Get-PSTypeExtension system.serviceprocess.servicecontroller -Members State | Export-PSTypeExtension -Path .\all.ps1xml -append
Export multiple type extensions to the same .ps1xml file. You can use Update-TypeData to load this file in another PowerShell session. Although, you might see errors if there is an existing type extension with the same name.
The type extension name.
Type: String[]
Parameter Sets: Name
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The name of the exported file. The extension must be .xml, .ps1xml or .json.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The type name to export like System.IO.FileInfo.
Type: String
Parameter Sets: Name
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is typically the output of Get-PSSTypeExtension.
Type: Object
Parameter Sets: Object
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Display the new file object.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/