about_Type_Accelerators

簡単な説明

.NET 型で使用できる型アクセラレータについて説明します。

長い説明

型アクセラレータは、.NET 型のエイリアスです。 これにより、完全な型名を明示的に使用せずに、特定の .NET 型にアクセスできます。 たとえば、[System.Management.Automation.AliasAttribute][Alias]に短縮できます。

型アクセラレータ名はほとんど小文字ですが、一部は Pascal-case を使用して定義されています。 PowerShell では大文字と小文字が区別されないため、どちらの方法でも使用できます。

型アクセラレータの使用

ほとんどの型アクセラレータでは、完全な型名を使用するのと同じ方法で型アクセラレータを使用します。 ただし、PowerShell には、次の 2 種類のアクセラレータに対する特別な処理があります。

型アクセラレータは、変数の型を指定したり、オブジェクトを特定の型にキャストしたりするために最も一般的に使用されます。 このような場合は、型名またはそのアクセラレータを角かっこ ([]) で囲む必要があります。 たとえば、[int][int32]などです。

コンテキストによっては、型アクセラレータ名を文字列として指定できます。 例えば:

  • 型比較演算子と共に使用する場合

    PS> '1' -as 'int'
    1
    PS> 1 -is 'int'
    True
    
  • [type] 型クラスと共に使用する場合

    PS> [type]'int'
    
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     True     Int32                                    System.ValueType
    

リフレクションなどの他のコンテキストでは、型アクセラレータ名ではなく、完全な型名を文字列として使用する必要があります。

既定の型アクセラレータ

アクセラレータ名 完全な型名
adsi System.DirectoryServices.DirectoryEntry
adsisearcher System.DirectoryServices.DirectorySearcher
エイリアス System.Management.Automation.AliasAttribute
AllowEmptyCollection System.Management.Automation.AllowEmptyCollectionAttribute
AllowEmptyString System.Management.Automation.AllowEmptyStringAttribute
[AllowNull](xref:System.Diagnostics.CodeAnalysis.AllowNullAttribute) System.Management.Automation.AllowNullAttribute
ArgumentCompleter System.Management.Automation.ArgumentCompleterAttribute
ArgumentCompletions System.Management.Automation.ArgumentCompletionsAttribute
アレイ System.Array
bigint System.Numerics.BigInteger
[bool] System.Boolean
byte System.Byte
char System.Char
cimclass Microsoft.Management.Infrastructure.CimClass
cimconverter Microsoft.Management.Infrastructure.CimConverter
ciminstance Microsoft.Management.Infrastructure.CimInstance
CimSession Microsoft.Management.Infrastructure.CimSession
cimtype Microsoft.Management.Infrastructure.CimType
CmdletBinding System.Management.Automation.CmdletBindingAttribute
cultureinfo System.Globalization.CultureInfo
datetime System.DateTime
10 進 System.Decimal
倍精度浮動小数点 System.Double
DscLocalConfigurationManager System.Management.Automation.DscLocalConfigurationManagerAttribute
DscProperty System.Management.Automation.DscPropertyAttribute
DscResource System.Management.Automation.DscResourceAttribute
ExperimentAction System.Management.Automation.ExperimentAction
実験用 System.Management.Automation.ExperimentalAttribute
ExperimentalFeature System.Management.Automation.ExperimentalFeature
float System.Single
guid System.Guid
hashtable System.Collections.Hashtable
initialsessionstate System.Management.Automation.Runspaces.InitialSessionState
int System.Int32
int16 System.Int16
int32 System.Int32
int64 System.Int64
ipaddress System.Net.IPAddress
IPEndpoint System.Net.IPEndPoint
long System.Int64
mailaddress System.Net.Mail.MailAddress
NoRunspaceAffinity System.Management.Automation.Language.NoRunspaceAffinityAttribute
NullString System.Management.Automation.Language.NullString
ObjectSecurity System.Security.AccessControl.ObjectSecurity
ordered System.Collections.Specialized.OrderedDictionary
OutputType System.Management.Automation.OutputTypeAttribute
パラメーター System.Management.Automation.ParameterAttribute
PhysicalAddress System.Net.NetworkInformation.PhysicalAddress
System.Management.Automation.PowerShell
psaliasproperty System.Management.Automation.PSAliasProperty
pscredential System.Management.Automation.PSCredential
pscustomobject System.Management.Automation.PSObject
PSDefaultValue System.Management.Automation.PSDefaultValueAttribute
pslistmodifier System.Management.Automation.PSListModifier
psmoduleinfo System.Management.Automation.PSModuleInfo
psnoteproperty System.Management.Automation.PSNoteProperty
psobject System.Management.Automation.PSObject
psprimitivedictionary System.Management.Automation.PSPrimitiveDictionary
pspropertyexpression Microsoft.PowerShell.Commands.PSPropertyExpression
psscriptmethod System.Management.Automation.PSScriptMethod
psscriptproperty System.Management.Automation.PSScriptProperty
PSTypeNameAttribute System.Management.Automation.PSTypeNameAttribute
psvariable System.Management.Automation.PSVariable
psvariableproperty System.Management.Automation.PSVariableProperty
ref System.Management.Automation.PSReference
RegEx System.Text.RegularExpressions.Regex
実行空間 System.Management.Automation.Runspaces.Runspace
runspacefactory System.Management.Automation.Runspaces.RunspaceFactory
sbyte System.SByte
scriptblock System.Management.Automation.ScriptBlock
securestring System.Security.SecureString
semver System.Management.Automation.SemanticVersion
short System.Int16
single System.Single
文字列 System.String
SupportsWildcards System.Management.Automation.SupportsWildcardsAttribute
switch System.Management.Automation.SwitchParameter
TimeSpan System.TimeSpan
System.Type
uint System.UInt32
uint16 System.UInt16
uint32 System.UInt32
uint64 System.UInt64
ulong System.UInt64
uri System.Uri
ushort System.UInt16
ValidateCount System.Management.Automation.ValidateCountAttribute
ValidateDrive System.Management.Automation.ValidateDriveAttribute
ValidateLength System.Management.Automation.ValidateLengthAttribute
ValidateNotNull System.Management.Automation.ValidateNotNullAttribute
ValidateNotNullOrEmpty System.Management.Automation.ValidateNotNullOrEmptyAttribute
ValidateNotNullOrWhiteSpace System.Management.Automation.ValidateNotNullOrWhiteSpaceAttribute
ValidatePattern System.Management.Automation.ValidatePatternAttribute
ValidateRange System.Management.Automation.ValidateRangeAttribute
ValidateScript System.Management.Automation.ValidateScriptAttribute
ValidateSet System.Management.Automation.ValidateSetAttribute
ValidateTrustedData System.Management.Automation.ValidateTrustedDataAttribute
ValidateUserDrive System.Management.Automation.ValidateUserDriveAttribute
バージョン System.Version
無効 System.Void
WildcardPattern System.Management.Automation.WildcardPattern
wmi System.Management.ManagementObject
wmiclass System.Management.ManagementClass
wmisearcher System.Management.ManagementObjectSearcher
X500DistinguishedName System.Security.Cryptography.X509Certificates.X500DistinguishedName
X509Certificate System.Security.Cryptography.X509Certificates.X509Certificate
xml System.Xml.XmlDocument