Wednesday, June 29, 2016

PowerShell v3 Type Accelerators Cheat and a lot of Hot Wind

,
This is straight off of Hals Google+.
[PSObject].Assembly.GetType(System.Management.Automation.TypeAccelerators)::Get.GetEnumerator() | sort key | select key 
Now, to get a little more into the arcane side of all things PowerShelly, heres a little sidenote (and history): this was shifted from being a public class in v2 to an internal class in v3 as indicated by James ONeill: System.Management.Automation.TypeAccelerators broken in V3 CTP2.

To get around to seeing whats buried in there with v3 you have to resort to a little trickery (calling the assembly itself...which references all exported objects...then drill down into the DLR indirectly). This explains why you are unable to see a "clean" list of TypeAccelerators in v3. For example, v3 shows the following with my hopped up command:
# Type accelarators
[PSObject].Assembly.GetType(System.Management.Automation.TypeAccelerators)::Get.GetEnumerator() |
sort key|
select key|
% {$_.key.ToString().Trim()}
and it returns:
adsi
adsisearcher
Alias
AllowEmptyCollection
AllowEmptyString
AllowNull
array
bigint
bool
byte
char
ciminstance
CmdletBinding
cultureinfo
datetime
decimal
double
float
guid
hashtable
int
int16
int32
int64
ipaddress
long
mailaddress
NullString
OutputType
Parameter
powershell
pscredential
pscustomobject
PSDefaultValue
pslistmodifier
psmoduleinfo
psobject
psprimitivedictionary
PSTypeNameAttribute
ref
regex
runspace
runspacefactory
sbyte
scriptblock
securestring
single
string
SupportsWildcards
switch
timespan
type
uint16
uint32
uint64
uri
ValidateCount
ValidateLength
ValidateNotNull
ValidateNotNullOrEmpty

0 comments to “PowerShell v3 Type Accelerators Cheat and a lot of Hot Wind”

Post a Comment

 

Computer Info Copyright © 2016 -- Powered by Blogger