Thursday, 4 December 2014

Measure-TypeAccelerator.ps1

<#
.SYNOPSIS
This function 'measures' (counts) the number of
Type Accelerators on your system.
.DESCRIPTION
This function counts the number of type accelerators are
on your systems and returns that number.
.NOTES
File Name : Measure-TypeAccelerator.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : Version 3
.LINK
Script Repository
http://www.pshscripts.blogspot.com
.Example
Psh[C:\foo]> Measure-TypeAccelerator.ps1
84
.Example
Psh[C:\foo]> Count-TypeAccelerator.ps1
84

#>

Function Measure-TypeAccelerator {
# Define parameters and enable advanced functions
# NB no parameters!
[cmdletbinding()]
Param ()

# Start of function
Write-Verbose 'Getting acount of all Type Accelerators'
$Count = (([PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get).GetEnumerator() |
Measure).count
Write-Verbose "$Count Type Accelerators found on $(hostname)"
Return $count
}

# Set an alias
Set-Alias CTA Measure-TypeAccelerator
Set-Alias MTA Measure-TypeAccelerator

No comments: