<# .SYNOPSIS This script defines a function to get a list of Type Accelerators in PowerShell and displays them nicely .DESCRIPTION This script gets the details of type accelerators in the system. Earlier versions of this script uses a different class, which has been taken private and is not available any more. This script also creates an alias for the function. GTA takes a string parameter which is used as a regular expression to find a subset of type accelerators. .NOTES Additional Notes, eg File Name : Get-TypeAccelerator.ps1 Author : Thomas Lee - tfl@psp.co.uk Requires : Version 3 .LINK Original article: http://www.nivot.org/2008/12/25/ListOfTypeAcceleratorsForPowerShellCTP3.aspx Script Repository http://www.pshscripts.blogspot.com .Example Psh[C:\foo]>Get-TypAccelerator int Name Type ---- ---- bigint System.Numerics.BigInteger int System.Int32 int16 System.Int16 int32 System.Int32 int64 System.Int64 uint16 System.UInt16 uint32 System.UInt32 uint64 System.UInt64 .Example Psh[C:\foo]>Get-TypAccelerator 's$' Name Type ---- ---- Alias System.Management.Automation.AliasAttribute cimclass Microsoft.Management.Infrastructure.CimClass ipaddress System.Net.IPAddress mailaddress System.Net.Mail.MailAddress SupportsWildcards System.Management.Automation.SupportsWildcardsAttribute wmiclass System.Management.ManagementClass #> ### # Start of script ### Function Get-TypeAccelerator { [Cmdletbinding()] param ( [string] $accelerator ) ([PSObject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::Get).getenumerator() | Select-object @{Name="Name"; expression={$_.key}}, @{name="Type"; expression={$_.value}} | where name -match $accelerator | Sort name | Format-Table -Autosize } Set-Alias gta Get-TypAccelerator # Test script Get-TypAccelerator int # anything with int Get-TypeAccelerator 's$' # ends in s
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Monday, 1 December 2014
Get-TypeAccelerator.ps1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment