Update-TypeData
更新会话中的扩展类型数据。
语法
FileSet (默认值)
Update-TypeData
[[-AppendPath] <String[]>]
[-PrependPath <String[]>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
DynamicTypeSet
Update-TypeData
-TypeName <String>
[-MemberType <PSMemberTypes>]
[-MemberName <String>]
[-Value <Object>]
[-SecondValue <Object>]
[-TypeConverter <Type>]
[-TypeAdapter <Type>]
[-SerializationMethod <String>]
[-TargetTypeForDeserialization <Type>]
[-SerializationDepth <Int32>]
[-DefaultDisplayProperty <String>]
[-InheritPropertySerializationSet <Nullable`1>]
[-StringSerializationSource <String>]
[-DefaultDisplayPropertySet <String[]>]
[-DefaultKeyPropertySet <String[]>]
[-PropertySerializationSet <String[]>]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
TypeDataSet
Update-TypeData
[-TypeData] <TypeData[]>
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Update-TypeData
cmdlet 通过将 Types.ps1xml
文件重新加载到内存中并添加新的扩展类型数据来更新会话中的扩展类型数据。
默认情况下,PowerShell 会根据需要加载扩展类型数据。 如果没有参数,Update-TypeData
会重新加载会话中加载的所有 Types.ps1xml
文件,包括添加的任何类型文件。 可以使用 Update-TypeData
的参数添加新类型文件并添加和替换扩展类型数据。
Update-TypeData
cmdlet 可用于预加载所有类型的数据。 当你开发类型并希望加载这些新类型以进行测试时,此功能特别有用。
从 Windows PowerShell 3.0 开始,可以使用 Update-TypeData
在会话中添加和替换扩展类型数据,而无需使用 Types.ps1xml
文件。 动态添加的类型数据(即不带文件)仅添加到当前会话中。 若要将类型数据添加到所有会话,请将 Update-TypeData
命令添加到 PowerShell 配置文件。 有关详细信息,请参阅 about_Profiles。
此外,从 Windows PowerShell 3.0 开始,可以使用 Get-TypeData
cmdlet 获取当前会话中的扩展类型,Remove-TypeData
cmdlet 从当前会话中删除扩展类型。
属性中发生的异常或从将属性添加到 Update-TypeData
命令时,不会报告错误。 这是为了禁止在格式化和输出过程中在很多常见类型中发生的异常。 如果你要获得 .NET 属性,可以通过改用方法语法来处理取消显示异常问题,如下面的示例所示:
"hello".get_Length()
请注意,方法语法只能与 .NET 属性一起使用。 通过运行 Update-TypeData
cmdlet 添加的属性不能使用方法语法。
有关 PowerShell 中的 Types.ps1xml
文件的详细信息,请参阅 about_Types.ps1xml。
示例
示例 1:更新扩展类型
Update-TypeData
此命令从会话中使用的 Types.ps1xml
文件更新扩展类型配置。
示例 2:多次更新类型
此示例演示如何在同一会话中多次更新类型文件中的类型。
第一个命令从 Types.ps1xml
文件更新扩展类型配置,首先处理 TypesA.types.ps1xml
和 TypesB.types.ps1xml
文件。
第二个命令演示如何再次更新 TypesA.types.ps1xml
,例如,如果添加或更改了文件中的类型,则可以执行此作。 可以为 TypesA.types.ps1xml
文件重复上一个命令,也可以运行不带参数的 Update-TypeData
命令,因为 TypesA.types.ps1xml
已在当前会话的类型文件列表中。
Update-TypeData -PrependPath TypesA.types.ps1xml, TypesB.types.ps1xml
Update-TypeData -PrependPath TypesA.types.ps1xml
示例 3:向 DateTime 对象添加脚本属性
此示例使用 Update-TypeData
将 Quarter 脚本属性 添加到当前会话中的 system.DateTime 对象,例如 Get-Date
cmdlet 返回的对象。
$typeDataParams = @{
TypeName = 'System.DateTime'
MemberType = 'ScriptProperty'
MemberName = 'Quarter'
Value = {
switch ($this.Month) {
{ $_ -in @(1, 2, 3) } { return 'Q1' }
{ $_ -in @(4, 5, 6) } { return 'Q2' }
{ $_ -in @(7, 8, 9) } { return 'Q3' }
default { return 'Q4' }
}
}
}
Update-TypeData @typeDataParams
(Get-Date).Quarter
Q1
Update-TypeData
命令使用 TypeName 参数来指定 system.DateTime 类型,MemberName 参数指定新属性的名称、MemberType 属性来指定 ScriptProperty 类型,以及 Value 参数来指定用于确定年度季度的脚本。
Value 属性的值是计算当前年度季度的脚本。 脚本块使用 $this
自动变量来表示对象的当前实例和 In 运算符,以确定月份值是否出现在每个整数数组中。 有关-in
运算符的详细信息,请参阅about_Comparison_Operators。
第二个命令获取当前日期的新 Quarter 属性。
示例 4:更新默认在列表中显示的类型
此示例演示如何设置默认在列表中显示的类型的属性,即未指定任何属性时。 由于类型数据未在 Types.ps1xml
文件中指定,因此仅在当前会话中有效。
Get-Date | Format-List
Update-TypeData -TypeName "System.DateTime" -DefaultDisplayPropertySet @(
'DateTime'
'DayOfYear'
'Quarter'
)
Get-Date | Format-List
DisplayHint : DateTime
Date : 8/7/2024 12:00:00 AM
Day : 7
DayOfWeek : Wednesday
DayOfYear : 220
Hour : 10
Kind : Local
Millisecond : 568
Minute : 34
Month : 8
Second : 43
Ticks : 638586236835683086
TimeOfDay : 10:34:43.5683086
Year : 2024
DateTime : Wednesday, August 7, 2024 10:34:43 AM
Quarter : Q3
DateTime : Wednesday, August 7, 2024 10:34:43 AM
DayOfYear : 220
Quarter : Q3
第一个命令显示 Get-Date
命令的列表视图,该命令输出表示当前日期的 System.DateTime 对象。 该命令使用管道运算符 (|
) 将 DateTime 对象发送到 Format-List
cmdlet。 由于 Format-List
命令未指定要在列表中显示的属性,因此 PowerShell 显示对象的每个公共非隐藏属性。
第二个命令使用 Update-TypeData
cmdlet 设置 System.DateTime 类型的默认列表属性。 该命令使用 TypeName 参数指定类型,DefaultDisplayPropertySet 参数指定列表的默认属性。 所选属性包括前面示例中添加的新 Quarter 脚本属性。
最后一个命令获取当前日期,并再次以列表格式显示它。 它仅显示 Update-TypeData
命令中定义的属性,而不是属性的完整列表。
示例 5:设置类型以宽格式显示的属性
此示例演示如何创建新的脚本属性,并将其用作将类型传递给 Format-Wide
cmdlet 时显示的默认属性。
Get-Command *File* | Format-Wide
Set-AppPackageProvisionedDataFile Set-ProvisionedAppPackageDataFile
Set-ProvisionedAppXDataFile Write-FileSystemCache
Write-FileSystemCache Block-FileShareAccess
Clear-FileStorageTier Close-SmbOpenFile
Debug-FileShare Disable-NetIPHttpsProfile
Enable-NetIPHttpsProfile Get-FileHash
Get-FileIntegrity Get-FileShare
Get-FileShareAccessControlEntry Get-FileStorageTier
Get-NetConnectionProfile Get-NetFirewallHyperVProfile
Get-NetFirewallProfile Get-SmbOpenFile
Get-StorageFileServer Get-SupportedFileSystems
Grant-FileShareAccess Import-PowerShellDataFile
New-FileShare New-NetFirewallHyperVProfile
New-ScriptFileInfo New-StorageFileServer
New-TemporaryFile Publish-BCFileContent
Remove-FileShare Remove-NetFirewallHyperVProfile
Remove-StorageFileServer Repair-FileIntegrity
Revoke-FileShareAccess Set-FileIntegrity
Set-FileShare Set-FileStorageTier
Set-NetConnectionProfile Set-NetFirewallHyperVProfile
Set-NetFirewallProfile Set-StorageBusProfile
Set-StorageFileServer Test-ScriptFileInfo
Unblock-FileShareAccess Update-ScriptFileInfo
Add-BitsFile Get-AIPFileStatus
Get-AppLockerFileInformation New-FileCatalog
New-PSRoleCapabilityFile New-PSSessionConfigurationFile
Out-File Set-AIPFileClassification
Set-AIPFileLabel Set-AppXProvisionedDataFile
Set-UevTemplateProfile Test-FileCatalog
Test-PSSessionConfigurationFile Unblock-File
FileDialogBroker.exe FileHistory.exe
forfiles.exe openfiles.exe
$typeDataParams = @{
TypeName = 'System.Management.Automation.CommandInfo'
DefaultDisplayProperty = 'FullyQualifiedName'
MemberType = 'ScriptProperty'
MemberName = 'FullyQualifiedName'
Value = {
[OutputType([string])]
param()
# For executables, return the path to the application.
if ($this -is [System.Management.Automation.ApplicationInfo]) {
return $this.Path
}
# For commands defined outside a module, return only the name.
if ([string]::IsNullOrEmpty($this.ModuleName)) {
return $this.Name
}
# Return the fully-qualified command name "<ModuleName>\<CommandName>"
return '{0}\{1}' -f $this.ModuleName, $this.Name
}
}
Update-TypeData @typeDataParams
Get-Command *File* | Format-Wide
Dism\Set-AppPackageProvisionedDataFile Dism\Set-ProvisionedAppPackageDataFile
Dism\Set-ProvisionedAppXDataFile Storage\Write-FileSystemCache
VMDirectStorage\Write-FileSystemCache Storage\Block-FileShareAccess
Storage\Clear-FileStorageTier SmbShare\Close-SmbOpenFile
Storage\Debug-FileShare NetworkTransition\Disable-NetIPHttpsProfile
NetworkTransition\Enable-NetIPHttpsProfile Microsoft.PowerShell.Utility\Get-FileHash
Storage\Get-FileIntegrity Storage\Get-FileShare
Storage\Get-FileShareAccessControlEntry Storage\Get-FileStorageTier
NetConnection\Get-NetConnectionProfile NetSecurity\Get-NetFirewallHyperVProfile
NetSecurity\Get-NetFirewallProfile SmbShare\Get-SmbOpenFile
Storage\Get-StorageFileServer Storage\Get-SupportedFileSystems
Storage\Grant-FileShareAccess Microsoft.PowerShell.Utility\Import-PowerShellDataFile
Storage\New-FileShare NetSecurity\New-NetFirewallHyperVProfile
PowerShellGet\New-ScriptFileInfo Storage\New-StorageFileServer
Microsoft.PowerShell.Utility\New-TemporaryFile BranchCache\Publish-BCFileContent
Storage\Remove-FileShare NetSecurity\Remove-NetFirewallHyperVProfile
Storage\Remove-StorageFileServer Storage\Repair-FileIntegrity
Storage\Revoke-FileShareAccess Storage\Set-FileIntegrity
Storage\Set-FileShare Storage\Set-FileStorageTier
NetConnection\Set-NetConnectionProfile NetSecurity\Set-NetFirewallHyperVProfile
NetSecurity\Set-NetFirewallProfile StorageBusCache\Set-StorageBusProfile
Storage\Set-StorageFileServer PowerShellGet\Test-ScriptFileInfo
Storage\Unblock-FileShareAccess PowerShellGet\Update-ScriptFileInfo
BitsTransfer\Add-BitsFile AzureInformationProtection\Get-AIPFileStatus
AppLocker\Get-AppLockerFileInformation Microsoft.PowerShell.Security\New-FileCatalog
Microsoft.PowerShell.Core\New-PSRoleCapabilityFile Microsoft.PowerShell.Core\New-PSSessionConfigurationFile
Microsoft.PowerShell.Utility\Out-File AzureInformationProtection\Set-AIPFileClassification
AzureInformationProtection\Set-AIPFileLabel Dism\Set-AppXProvisionedDataFile
UEV\Set-UevTemplateProfile Microsoft.PowerShell.Security\Test-FileCatalog
Microsoft.PowerShell.Core\Test-PSSessionConfigurationFile Microsoft.PowerShell.Utility\Unblock-File
C:\WINDOWS\system32\FileDialogBroker.exe C:\WINDOWS\system32\FileHistory.exe
C:\WINDOWS\system32\forfiles.exe C:\WINDOWS\system32\openfiles.exe
第一个命令使用 Get-Command
cmdlet 返回包含单词 File
的名称的每个命令。 它通过管道将输出传递给 Format-Wide
cmdlet,该 cmdlet 显示列中命令的名称。
接下来,该示例使用 Update-TypeData
定义 DefaultDisplayProperty 和 CommandInfo 类型的新脚本属性。
Get-Command
的输出返回 CommandInfo 派生自该类型的对象和对象。 新的脚本属性,FullyQualifiedName,返回可执行应用程序的完整路径和 cmdlet 的完全限定名称,该名称为 cmdlet 名称加上定义它的模块前缀。
Update-TypeData
cmdlet 能够定义新的脚本属性,并将其用作同一命令中的 DefaultDisplayProperty。
最后,输出显示类型更新后以宽格式显示的 Get-Command
的结果。 它显示 cmdlet 的完全限定名称以及可执行应用程序的完整路径。
示例 6:更新管道对象的类型数据
$typeDataParams = @{
MemberType = 'ScriptProperty'
MemberName = 'SupportsUpdatableHelp'
Value = {
[OutputType([bool])]
param()
return (-not [string]::IsNullOrEmpty($this.HelpInfoUri))
}
}
Get-Module Microsoft.PowerShell.Utility | Update-TypeData @typeDataParams
Get-Module -ListAvailable -Name Microsoft.PowerShell.* |
Format-Table Name, SupportsUpdatableHelp
Name SupportsUpdatableHelp
---- ---------------------
Microsoft.PowerShell.Operation.Validation True
Microsoft.PowerShell.Archive True
Microsoft.PowerShell.Diagnostics True
Microsoft.PowerShell.Host True
Microsoft.PowerShell.LocalAccounts True
Microsoft.PowerShell.Management True
Microsoft.PowerShell.ODataUtils True
Microsoft.PowerShell.Security True
Microsoft.PowerShell.Utility True
此示例演示在通过管道将对象传递给 Update-TypeData
时,Update-TypeData
为对象类型添加扩展类型数据。
此方法比使用 Get-Member
cmdlet 或 Get-Type
方法获取对象类型要快。 但是,如果通过管道将对象集合传递给 Update-TypeData
,它将更新第一个对象类型的类型数据,然后返回集合中所有其他对象的错误,因为该成员已在类型上定义。
第一个命令使用 Get-Module
cmdlet 获取 Microsoft.PowerShell.Utility 模块。
该命令通过管道将模块对象传递给 Update-TypeData
cmdlet,该 cmdlet 会更新 System.Management.Automation.PSModuleInfo 类型和派生自它的类型,例如 ModuleInfoGrouping 类型,Get-Module
在命令中使用 ListAvailable 参数时返回。
Update-TypeData
命令将 SupportsUpdatableHelp 脚本属性添加到所有导入的模块。
Value 参数的值是一个脚本,如果填充模块的 $true
属性并 ,则返回 $false
。
第二个命令通过管道将模块对象从 Get-Module
传递给 Format-Table
cmdlet,该 cmdlet 显示 Name 和 SupportsUpdatableHelp 可用模块的属性。
参数
-AppendPath
指定可选 .ps1xml
文件的路径。 按加载内置文件后列出的顺序加载指定的文件。 还可以通过管道将 AppendPath 值传递给 Update-TypeData
。
参数属性
类型: | String[] |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | PSPath, 路径 |
参数集
FileSet
Position: | 0 |
必需: | False |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-Confirm
在运行 cmdlet 之前,提示你进行确认。
参数属性
类型: | SwitchParameter |
默认值: | False |
支持通配符: | False |
不显示: | False |
别名: | cf |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-DefaultDisplayProperty
指定未指定其他属性时由 Format-Wide
cmdlet 显示的类型的属性。
键入该类型的标准或扩展属性的名称。 此参数的值可以是在同一命令中添加的类型的名称。
仅当 Format.ps1xml
文件中没有为类型定义宽视图时,此值才有效。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-DefaultDisplayPropertySet
指定类型的一个或多个属性。 如果未指定其他属性,这些属性由 Format-List
、Format-Table
和 Format-Custom
cmdlet 显示。
键入该类型的标准或扩展属性的名称。 此参数的值可以是在同一命令中添加的类型的名称。
仅当没有为 Format.ps1xml
文件中的类型定义的列表、表或自定义视图时,此值才有效。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | String[] |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-DefaultKeyPropertySet
指定类型的一个或多个属性。 如果未指定其他属性,Group-Object
和 Sort-Object
cmdlet 使用这些属性。
键入该类型的标准或扩展属性的名称。 此参数的值可以是在同一命令中添加的类型的名称。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | String[] |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Force
指示该 cmdlet 使用指定的类型数据,即使已为该类型指定类型数据也是如此。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
TypeDataSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-InheritPropertySerializationSet
指示是否继承序列化的属性集。 默认值是 $null
。 此参数的可接受值为:
-
$true
。 属性集继承。 -
$false
。 属性集不继承。 -
$null
。 未定义继承。
仅当 SerializationMethod 参数的值 SpecificProperties
时,此参数才有效。 当此参数的值 $false
时,需要 PropertySerializationSet 参数。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-MemberName
指定属性或方法的名称。
将此参数与 TypeName、MemberType、Value 和 SecondValue 参数一起使用,以添加或更改类型的属性或方法。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-MemberType
指定要添加或更改的成员的类型。
将此参数与 TypeName、MemberType、Value 和 SecondValue 参数一起使用,以添加或更改类型的属性或方法。 此参数的可接受值为:
- AliasProperty
- CodeMethod
- CodeProperty
- Note属性
- ScriptMethod
- ScriptProperty
有关这些值的信息,请参阅 PSMemberTypes 枚举。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | PSMemberTypes |
默认值: | None |
接受的值: | NoteProperty, AliasProperty, ScriptProperty, CodeProperty, ScriptMethod, CodeMethod |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-PrependPath
指定可选 .ps1xml
文件的路径。 按照在加载内置文件之前列出指定的文件的顺序加载指定的文件。
参数属性
类型: | String[] |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
FileSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-PropertySerializationSet
指定序列化的属性的名称。 当 SerializationMethod 参数的值 SpecificProperties时,请使用此参数。
参数属性
类型: | String[] |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-SecondValue
指定 AliasProperty、ScriptProperty、CodeProperty或 CodeMethod 成员的其他值。
将此参数与 TypeName、MemberType、Value和 SecondValue 参数一起使用,以添加或更改类型的属性或方法。
当 MemberType 参数的值 AliasProperty
时,SecondValue 参数的值必须是数据类型。 PowerShell 将别名属性的值转换为指定类型(即强制转换)。 例如,如果添加为字符串属性提供备用名称的别名属性,还可以指定 System.Int32 的 SecondValue,以将别名字符串值转换为整数。
当 MemberType 参数的值 ScriptProperty
时,可以使用 SecondValue 参数指定其他脚本块。
Value 参数的值中的脚本块获取变量的值。
SecondValue 参数的值中的脚本块设置变量的值。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | Object |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-SerializationDepth
指定将类型对象的级别序列化为字符串的数量。 默认值 1
序列化对象及其属性。
0
的一个值序列化对象,但不序列化其属性。
2
的值序列化对象、其属性和属性值中的任何对象。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | Int32 |
默认值: | 1 |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-SerializationMethod
指定类型的序列化方法。 序列化方法确定序列化类型的哪些属性以及用于序列化这些属性的技术。 此参数的可接受值为:
-
AllPublicProperties
。 序列化类型的所有公共属性。 可以使用 SerializationDepth 参数来确定子属性是否序列化。 -
String
。 将类型序列化为字符串。 可以使用 StringSerializationSource 指定要用作序列化结果的类型的属性。 否则,使用对象的 ToString 方法序列化类型。 -
SpecificProperties
。 仅序列化此类型的指定属性。 使用 PropertySerializationSet 参数指定序列化类型的属性。 还可以使用 InheritPropertySerializationSet 参数来确定属性集是否继承,以及 SerializationDepth 参数以确定子属性是否序列化。
在 PowerShell 中,序列化方法存储在 PSStandardMembers 内部对象中。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-StringSerializationSource
指定类型的属性的名称。 指定属性的值用作序列化结果。 仅当 SerializationMethod 参数的值为 String 时,此参数才有效。
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-TargetTypeForDeserialization
指定反序列化此类型的对象转换为的类型。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | Type |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-TypeAdapter
指定类型适配器的类型,例如 Microsoft.PowerShell.Cim.CimInstanceAdapter。 类型适配器使 PowerShell 能够获取类型的成员。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | Type |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-TypeConverter
指定要在不同类型之间转换值的类型转换器。 如果为类型定义了类型转换器,则类型转换器的实例用于转换。
输入派生自 System.ComponentModel.TypeConverter 或 System.Management.Automation.PSTypeConverter 类的 System.Type 值。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | Type |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-TypeData
指定此 cmdlet 添加到会话的类型数据的数组。 输入包含 TypeData 对象的变量或获取 TypeData 对象的命令,例如 Get-TypeData
命令。 还可以通过管道将 TypeData 对象传递给 Update-TypeData
。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | TypeData[] |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
TypeDataSet
Position: | 0 |
必需: | True |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-TypeName
指定要扩展的类型的名称。
对于 系统 命名空间中的类型,请输入短名称。 否则,需要完整类型名称。 不支持通配符。
可以通过管道将类型名称传递给 Update-TypeData
。 通过管道将对象传递给 Update-TypeData
时,Update-TypeData
将对象的类型名称和类型数据获取到对象类型。
将此参数与 MemberName、MemberType、Value 和 SecondValue 参数一起使用,以添加或更改类型的属性或方法。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | True |
来自管道的值: | True |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Value
指定属性或方法的值。
如果添加 AliasProperty
、CodeProperty
、ScriptProperty
或 CodeMethod
成员,则可以使用 SecondValue 参数添加其他信息。
将此参数与 MemberName、MemberType、Value 和 SecondValue 参数一起使用,以添加或更改类型的属性或方法。
此参数是在 Windows PowerShell 3.0 中引入的。
参数属性
类型: | Object |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
DynamicTypeSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 命令脚本未运行。
参数属性
类型: | SwitchParameter |
默认值: | False |
支持通配符: | False |
不显示: | False |
别名: | 无线 |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输入
String
可以通过管道将包含 AppendPath、TypeName的值或 TypeData 参数的字符串传递给此 cmdlet。
输出
None
此 cmdlet 不返回任何输出。