Scripting Games, Beginner Event 2, True Type

A lot easier!  Display the names of the True Type fonts installed on the computer followed by a count of the True Type fonts and the overall number of fonts:

Simple registry lookup for 10 points

Here it is:

  1 $fonts=Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
  4 $fonts=$fonts.psbase.members|?{$_.membertype -eq "NoteProperty"}
  5 
  7 $TrueTypeNames=$fonts|?{$_.name -like '*(TrueType)'}|%{$_.name}|sort
  8 
 10 $TrueTypeNames   # Display True Type font names
 11 
 12 "`nTrueType: $($TrueTypeNames.Count)"
 13 "Total: $($fonts.Count)"

Reviewing other answers show some simpler solutions!  /\/\O\/\/ uses the much simpler -match operator to select True Type fonts (http://thepowershellguy.com/blogs/posh/archive/2008/02/20/scripting-games-2008-beginners-windows-powershell-event-2.aspx).

Hindsight is wonderful!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s