Sunday, 30 November 2008

Get-FreeMemory.ps1

# Get-FreeMemory.ps1
#
Sample using PowerShell
#
1st sample from http://msdn.microsoft.com/en-us/library/aa394587
#
Thomas Lee

$mem = Get-WmiObject -Class Win32_OperatingSystem

# Display memory
"System : {0}" -f $mem.csname
"Free Memory: {0}" -f $mem.FreePhysicalMemory



This script produces the following output:



PS C:\foo> .\get-freememory.ps1
System : COOKHAM8
Free Memory: 2776988

Saturday, 29 November 2008

Add-DomainUserToLocalAdministatorsGroup.ps1

#Requires -Version 2.0
#
Add-DomainUserToLocalAdministatorsGroup.ps1
#
Add a domain user to a Local Administrator's group
#
Thomas Lee - tfl@psp.co.uk
#
Based on http://powershell.com/cs/media/p/380.aspx, with some error checking

# Setup up information on user to add,etc
$Domain = "Cookham" # where the user account comes from
$Computer = "Cookham8" # Computer to add the user to
$User = "tfl" # User

# Try to add user to Administrator's group
try {
$group.Add("WinNT://" + $Domain + "/" + $User)
"User {0}\{1} added to Administrator's local group in system: {2}" -f $domain,$user, $computer
}
catch {
"Error adding user to Administrator's group"
}
""
# Now print results
$computer = [ADSI]("WinNT://" + $Computer + ",computer")
$group = $computer.psbase.children.find("Administrators")

"Group: {0} contains {1} members:" -f $group.Name.Value, $members.Length
$members = $group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name",'GetProperty',$null,$_,$null)}
$members
This script produces the following output (assuming no errors!):
PS C:\foo> .\Add-DomainUserToLocalAdministatorsGroup.ps1
User Cookham\tfl added to Administrator's local group in system: Cookham8

Group: Administrators contains 3 members:
Administrator
Domain Admins
tfl


Technorati Tags: ,,

Friday, 28 November 2008

Get-Forest.ps1

<#
.SYNOPSIS
    Shows use of GetCurrentForest to return information about the forest  
.DESCRIPTION
    This script uses .NET to return name of forest. 
.NOTES
    File Name  : Get-Forest.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V2
.LINK
    http://pshscripts.blogspot.com/2008/11/get-forestps1.html
.EXAMPLE
    PS c:\foo> .\Get-Forest.ps1
    You are connected to the Cookham.NET forest
#>

##
#  Start of script
##

# Get Forest name
$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 

# Display info
"You are connected to the {0} forest" -f $forest.name

Thursday, 27 November 2008

Get-SQLServer.ps1

<#
.SYNOPSIS
This script uses SQL Server Server SMO objects to display
    server information.
.DESCRIPTION
This script first loads the SMO assembly and then creates a
    server object. The script then prints basic server information
    plus details of databases and
tables.
.NOTES
File Name : Get-SQLServer.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell Version 3.0, SQL Server 2012
.LINK
This script posted to:
http://pshscripts.blogspot.com/2010/05/get-sqlserverps1.html
.EXAMPLE
C:\Foo> .\Get-SQLServer.ps1
Server Details
--------------
Server Name: SQL2012
Product: Microsoft SQL Server
Edition: Enterprise Edition (64-bit)
Type: Standalone
Version: 11.0.3000
Version String: 11.0.2000.0
Service Account: NT AUTHORITY\NETWORKSERVICE

Databases and Table
-------------------
master (contains 6 tables)
model (contains 0 tables)
msdb (contains 102 tables)
PSMC (contains 1 tables)
ReportServer (contains 34 tables)
ReportServer (contain 13 tables)
tempdb (contains 0 tables)
#>

##
# Start of Script
##

# Load the SMO Assemblies - installed with the module!
# Note this generates a warning since SQL module uses non-standard verb!
Import-Module SQLPS

# Create Server Object
$server = New-Object Microsoft.SqlServer.Management.Smo.Server 'SQL2-12'

# Display key properties
'Server Details'
'--------------'
'Server Name: {0}' -f $Server.Netname
'Product: {0}' -f $Server.Product
'Edition: {0}' -f $Server.Edition
'Type: {0}' -f $Server.ServerType
'Version: {0}' -f $Server.Version
'Version String: {0}' -f $Server.Versionstring
'Service Account: {0}' -f $Server.ServiceAccount
''

# Display Database/Table info
'Databases and Table'
'-------------------'
Foreach ($database in $server.Databases) {
'{0} (contains {1} tables)' -f $Database.Name, $Database.Tables.Count
}

Wednesday, 26 November 2008

Get-LocalGroup.ps1


<#
.SYNOPSIS
Gets local group members from a computer.
.DESCRIPTION
This script uses Win32_Group to get the local groups
on a system then displays those groups.
.NOTES
File Name : Get-LocalGroup.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2
.LINK
PowerShell sample at:
http://pshscripts.blogspot.co.uk/2008/11/get-localgroupsps1.html
.EXAMPLE
C:\foo> .\Get-LocalGroup.PS1

Name Sid SidType Status
---- --- ------- ------
Administrators S-1-5-32-544 4 OK
Backup Operators S-1-5-32-551 4 OK
Certificate Service… S-1-5-32-574 4 OK
Cryptographic Opera… S-1-5-32-569 4 OK
Distributed COM Users S-1-5-32-562 4 OK
Event Log Readers S-1-5-32-573 4 OK
Guests S-1-5-32-546 4 OK
IIS_IUSRS S-1-5-32-568 4 OK
Network Configuration … S-1-5-32-556 4 OK
Performance Log Users S-1-5-32-559 4 OK
Performance Monitor Us… S-1-5-32-558 4 OK
Power Users S-1-5-32-547 4 OK
Print Operators S-1-5-32-550 4 OK
Remote Desktop Users S-1-5-32-555 4 OK
Replicator S-1-5-32-552 4 OK
Users S-1-5-32-5 4 OK
SQLServer2005MSFTE… S-1-5-21-23769… 4 OK
SQLServer2005MSSQLSe… S-1-5-21-23769… 4 OK
SQLServer2005MSSQLUs… S-1-5-21-23769… 4 OK
SQLServer2005MSSQLUs… S-1-5-21-23769… 4 OK
SQLServer2005SQLBro S-1-5-21-23769… 4 OK
#>

##
# Start of script
##

# Get Win32 Group Accounts
$Accts = Get-WMIObject Win32_Group | Where-object {$_.LocalAccount}


# Display them
$accts | Format-Table Name, Sid, SidType, Status –Autosize

# End of script

 

Tuesday, 25 November 2008

Get-Domain.ps1

<#
.SYNOPSIS
    Uses Win32_ComputerSystem to determine the domain this computer is in
.DESCRIPTION
    This script is a re-write of an MSDN sample (sample three
    from  http://msdn.microsoft.com/en-us/library/aa394586) that uses
    Win32_computer name to determine the domain.
.NOTES
    File Name  : Get-Domain.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V2
.LINK
    Script posted to:
        Http://www.pshscripts.blogspot.com
    MSDN Sample at:
        http://msdn.microsoft.com/en-us/library/aa394586
.EXAMPLE
    PSH [C:\foo]: .\Get-Domain.PS1'
    System Name: COOKHAM8
    Domain     : cookham.net
#>

##
# Start of script
##

# Get details of this computer
$computer =  Get-WmiObject -Class Win32_ComputerSystem

# Display details
"System Name: {0}" -f $computer.name
"Domain     : {0}" -f $computer.domain
# End of script

Monday, 24 November 2008

Get-DomainRole.ps1

<#
.SYNOPSIS
    Gets and displays the role a computer plays in a domain
.DESCRIPTION
    This script uses WIN32_ComputerSystem to get the rold of a
    system then displays it. This is a re-write of an MSDN sample.
.NOTES
    File Name  : Get-DomainRole.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V2
.LINK
    PowerShell script posted to:
        http://pshscripts.blogspot.com/2008/11/get-domainroleps1.html
    MSDN sample at:
        http://pshscripts.blogspot.com/2008/11/get-domainroleps1.html
.EXAMPLE
    PSH [C:\foo]: .\Get-DomainRole.PS1
    Computer "COOKHAM8.cookham.net" is a:
    Member Server
#>

##
# Start of Script
##

# Get Computer info
$Computer = Get-WmiObject -Class Win32_ComputerSystem

# Print Role:
"Computer `"{0}.{1}`" is a: " -f $Computer.Name,$computer.domain
switch ($computer.DomainRole) {
0 {"Standalone Workstation"}
1 {"Member Workstation"}
2 {"Standalone Server"}
3 {"Member Server"}
4 {"Backup Domain Controller"}
5 {"Primary Domain Controller"}
}
#End of script

Sunday, 23 November 2008

Catch-Error.ps1

<#
.SYNOPSIS
    Demonstrates try/catch/finally in V2
.DESCRIPTION
    Shows a simple example of the try/catch/finally syntax
    introduced into PowerShell V2 CTP3 . The script divides by
    zero which creates an exception. The PowerShell parser
    is smart enough to recognise any attempt to divide 
    by "0" and therefore does not generate the run time error.
.NOTES
    File Name  : Show-TryCatchFinally.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V2
.LINK
   http://pshscripts.blogspot.com/2008/11/catch-errorps1.html
#>

##
# Start of script
##

# Try something that fails
$one=1
$zero=0
Try
  { 
      $one/$zero
  }
Catch{
 'Caught in a catch block'
 $Error[0]
}
Finally {'All done with trying and catching'
}

Saturday, 22 November 2008

Get-DiskDriveToDiskPartition.ps1

<#
.SYNOPSIS
   Shows details from WMI's Win32_DiskDriveToPartition class
.DESCRIPTION
    This script shows details of disk drives on a system using 
    several Win32_* classes
.NOTES
    File Name  : Get-DiskDrivetoDiskPartition.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V2
.LINK
    http://pshscripts.blogspot.com/2008/11/get-diskdrivetodiskpartitionps1.html
.EXAMPLE
    PSH [C:\foo]: . 'E:\PowerShellScriptLib\WMI\Get-Win32DiskDriveToDiskPartition.ps1'
    Win32_DiskDriveToDiskPartition
    Antecedent : \\COOKHAM8\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE5"
    Dependent  : \\COOKHAM8\root\cimv2:Win32_DiskPartition.DeviceID="Disk #5, Partition #0"

    Antecedent : \\COOKHAM8\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
    Dependent  : \\COOKHAM8\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #0"

    Antecedent : \\COOKHAM8\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
    Dependent  : \\COOKHAM8\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #1"

    Antecedent : \\COOKHAM8\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
    Dependent  : \\COOKHAM8\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #2"

    Antecedent : \\COOKHAM8\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
    Dependent  : \\COOKHAM8\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #3"
    
    Antecedent : \\COOKHAM8\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE6"
    Dependent  : \\COOKHAM8\root\cimv2:Win32_DiskPartition.DeviceID="Disk #6, Partition #0"

    Win32_DiskDrive

    Partitions DeviceID           Model                                          Size Caption
    ---------- --------           -----                                          ---- -------
             1 \\.\PHYSICALDRIVE5 WD My Book IEEE 1394 SBP2 Device      2000388096000 WD My Book IEEE 1394 SBP2 D...
             4 \\.\PHYSICALDRIVE0 ATA Hitachi HDS72107 SCSI Disk Device  750153761280 ATA Hitachi HDS72107 SCSI D...
             0 \\.\PHYSICALDRIVE1 TEAC USB   HS-CF Card USB Device                    TEAC USB   HS-CF Card USB D...
             0 \\.\PHYSICALDRIVE3 TEAC USB   HS-MS Card USB Device                    TEAC USB   HS-MS Card USB D...
             0 \\.\PHYSICALDRIVE4 TEAC USB   HS-SD Card USB Device                    TEAC USB   HS-SD Card USB D...
             0 \\.\PHYSICALDRIVE2 TEAC USB   HS-xD/SM USB Device                      TEAC USB   HS-xD/SM USB Device
             1 \\.\PHYSICALDRIVE6 WD My Book USB Device                 2000388096000 WD My Book USB Device

    Win32_DiskPartition

    NumberOfBlocks   : 144522
    BootPartition    : False
    Name             : Disk #0, Partition #0
    PrimaryPartition : True
    Size             : 73995264
    Index            : 0
    
    NumberOfBlocks   : 4209030
    BootPartition    : True
    Name             : Disk #0, Partition #1
    PrimaryPartition : True
    Size             : 2155023360
    Index            : 1
    
    NumberOfBlocks   : 102400000
    BootPartition    : False
    Name             : Disk #0, Partition #2
    PrimaryPartition : True
    Size             : 52428800000
    Index            : 2
    
    NumberOfBlocks   : 1358391296
    BootPartition    : False
    Name             : Disk #0, Partition #3
    PrimaryPartition : False
    Size             : 695496343552
    Index            : 3
    
    NumberOfBlocks   : 3907012608
    BootPartition    : False
    Name             : Disk #5, Partition #0
    PrimaryPartition : True
    Size             : 2000390455296
    Index            : 0

    NumberOfBlocks   : 3907012608
    BootPartition    : False
    Name             : Disk #6, Partition #0
    PrimaryPartition : True
    Size             : 2000390455296
    Index            : 0
#>

##
# Start of Script
##

# First, display Win32DiskDriveToDiskPartition class
# Only show two key properties
"Win32_DiskDriveToDiskPartition"
Get-WmiObject Win32_DiskDriveToDiskPartition | fl Antecedent, Dependent

# Show the other related classes
# First Win32_DiskDrive
"";"Win32_DiskDrive"
Get-WmiObject Win32_DiskDrive | ft -autosize

# And now related Disk Partitions
"";"Win32_DiskPartition"
Get-WmiObject Win32_DiskPartition | sort name

# End of script

Friday, 21 November 2008

Display-Array1.ps1

<#
.SYNOPSIS
    Display's an Array    
.DESCRIPTION
    This script displays the values in an arra
.NOTES
    File Name  : Display-Array1.ps1
	Author     : Thomas Lee - tfl@psp.co.uk
	Requires   : PowerShell V2
.LINK
    http://www.pshscripts.blogspot.com
.EXAMPLE
    PSH [C:\foo]: .\Display-Array1.ps1'
    Initially,
    Integer array:
        1
        2
        3
        4
        5

    Object array:
        26
        27
        28
        29
        30

    After copying the first two elements of the integer array to the Object array,
    Integer array:
        1
        2
        3
        4
        5

    Object array:
        1
        2
        28
        29
        30

    After copying the last two elements of the Object array to the integer array,
    integer array:
        1
        2
        3
        29
        30

    Object array:
        1
        2
        28
        29
        30
#> 

##
#  Start of script
##

# Helper function
Function PrintValues{ 
[Cmdletbinding()]
Param ($myArr )  

ForEach ( $i in $myArr )
  {
    "`t{0}" -f $i
  }
""
}
 
# Start of Sample
# Creates and initializes a new integer array and a new Object array.
$IntArray =  1, 2, 3, 4, 5 
[system.object] $ObjArray = [object] 26, [object] 27, [object] 28,[object] 29,[object] 30

# Prints the initial values of both arrays.
"Initially,"
"Integer array:" 
PrintValues( $IntArray )
"Object array: " 
PrintValues( $ObjArray );

# Copies the first two elements from the integer array to the Object array.
[System.Array]::Copy( $IntArray, $ObjArray, 2)
 
# Prints the values of the modified arrays.
"`nAfter copying the first two elements of the integer array to the Object array," 
"Integer array:" 
PrintValues( $IntArray );
"Object array: " 
PrintValues( $ObjArray );

# Copies the last two elements from the Object array to the integer array.
[System.Array]::Copy( $ObjArray, $ObjArray.GetUpperBound(0) - 1, $IntArray, $IntArray.GetUpperBound(0) - 1, 2 )

# Prints the values of the modified arrays.
"`nAfter copying the last two elements of the Object array to the integer array," 
"integer array:"
PrintValues( $IntArray )
"Object array: "
PrintValues( $ObjArray )

Thursday, 20 November 2008

Display-TimeSpan.ps1

<#
.SYNOPSIS
Creates timespan objects and displays properties for each
.DESCRIPTION
This script creates time span objects then displays
the properties of each one.
.NOTES
File Name : Display-TimeSpan.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2
.LINK
http://pshscripts.blogspot.co.uk/2008/11/display-timespanps1.html
.EXAMPLE
PSH [C:\foo]: .\Display-Timespan.ps1
This example of the TimeSpan class properties
generates the following output. It creates
several TimeSpan objects and displays the values
of the TimeSpan properties for each

TimeSpan( 1 )
Interval = 00:00:00.0000001
Days 0 TotalDays 1.15740740740741E-12
Hours 0 TotalHours 2.77777777777778E-11
Minutes 0 TotalMinutes 1.66666666666667E-09
Seconds 0 TotalSeconds 1E-07
Milliseconds 0 TotalMilliseconds 0.0001
Ticks 1
TimeSpan( 111222333444555 )
Interval = 128.17:30:33.3444555
Days 128 TotalDays 128.729552597865
Hours 17 TotalHours 3089.50926234875
Minutes 30 TotalMinutes 185370.555740925
Seconds 33 TotalSeconds 11122233.3444555
Milliseconds 344 TotalMilliseconds 11122233344.4555
Ticks 111222333444555

TimeSpan( 10, 20, 30, 40, 50 )
Interval = 10.20:30:40.0500000
Days 10 TotalDays 10.8546302083333
Hours 20 TotalHours 260.511125
Minutes 30 TotalMinutes 15630.6675
Seconds 40 TotalSeconds 937840.05
Milliseconds 50 TotalMilliseconds 937840050
Ticks 9378400500000
TimeSpan( 1111, 2222, 3333, 4444, 5555 )
Interval = 1205.22:47:09.5550000
Days 1205 TotalDays 1205.94941614583
Hours 22 TotalHours 28942.7859875
Minutes 47 TotalMinutes 1736567.15925
Seconds 9 TotalSeconds 104194029.555
Milliseconds 555 TotalMilliseconds 104194029555
Ticks 1041940295550000
FromDays( 20.84745602 )
Interval = 20.20:20:20.1980000
Days 20 TotalDays 20.8474559953704
Hours 20 TotalHours 500.338943888889
Minutes 20 TotalMinutes 30020.3366333333
Seconds 20 TotalSeconds 1801220.198
Milliseconds 198 TotalMilliseconds 1801220198
Ticks 18012201980000

#>

##
# Start of Script
##

# Constant
$HeaderFmt = "`n{0, -45}"
$DataFmt = "{0,-12}{1,8} {2,-18}{3,21}"

# Helper function
function ShowTimeSpanProperties {
param ([System.TimeSpan] $Interval = 1)

# Display the properties of the TimeSpan parameter.

"Interval = {0,21}" -f $interval
"$DataFmt" -f "Days", $interval.Days, "TotalDays", $interval.TotalDays
"$DataFmt" -f "Hours", $interval.Hours, "TotalHours", $interval.TotalHours
"$dataFmt" -f "Minutes", $interval.Minutes, "TotalMinutes", $interval.TotalMinutes
"$DataFmt" -f "Seconds", $interval.Seconds, "TotalSeconds", $interval.TotalSeconds
"$DataFmt" -f "Milliseconds", $interval.Milliseconds, "TotalMilliseconds", $interval.TotalMilliseconds
"$DataFmt" -f $null, $null, "Ticks", $interval.Ticks
}

# Start of main script
# Create and display a comment
$comment = @"
This example of the TimeSpan class properties
generates the following output. It creates
several TimeSpan objects and displays the values
of the TimeSpan properties for each
"@
$comment

# Create and display a TimeSpan value of 1 tick.
$ts = [system.TimeSpan] 1
"$HeaderFmt" -f "TimeSpan( 1 )"
ShowTimeSpanProperties($ts)

# Create a TimeSpan value with a large number of ticks.
$ts = [System.TimeSpan] 111222333444555
"$HeaderFmt" -f "TimeSpan( 111222333444555 )"
ShowTimeSpanProperties($ts)

# This TimeSpan has all fields specified.
$ts = New-Object System.TimeSpan 10, 20, 30, 40, 50
"$HeaderFmt" -f "TimeSpan( 10, 20, 30, 40, 50 )"
ShowTimeSpanProperties($ts)

# This TimeSpan has all fields overflowing.
$ts = New-Object System.Timespan 1111, 2222, 3333, 4444, 5555
"$HeaderFmt" -f "TimeSpan( 1111, 2222, 3333, 4444, 5555 )"
ShowTimeSpanProperties($ts)

# This TimeSpan is based on a number of days.
$ts = [system.TimeSpan] ([system.TimeSpan]::FromDays(20.8474560))
"$headerFmt" -f "FromDays( 20.84745602 )"

ShowTimeSpanProperties($ts)

# End of script

Wednesday, 19 November 2008

Send-SMTPMessage.ps1

<#
.SYNOPSIS
Creates and sends an SMTP message
.DESCRIPTION
This script uses the system.net.mail class to create and send
an email message using SMTP.
.NOTES
File Name : Send-SMTPMessage.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2
.LINK
http://pshscripts.blogspot.co.uk/2008/11/send-smtpmessageps1.html
.EXAMPLE
PSH [C:\foo]: .\Send-SMTPMessage.ps1'
Sending an e-mail message to doctordns@gmail.com by using SMTP host localhost port 25.
Message to: powershell@psp.co.uk, from: doctordns@gmail.com has been successfully sent
#>

##
# Start of Script
##

# Create from/to addresses
$from = New-Object System.Net.Mail.MailAddress "powershell@psp.co.uk"
$to = New-Object System.Net.Mail.MailAddress "doctordns@gmail.com"

# Create Message
$message = new-object System.Net.Mail.MailMessage $from, $to
$message.Subject = "Using the SmtpClient class and PowerShell"
$message.Body = @"
Using this feature, you can send an e-mail message from an application very easily.
"@

# Set SMTP Server and create SMTP Client
$server = "localhost"
$client = new-object system.net.mail.smtpclient $server

# Send the message
"Sending an e-mail message to {0} by using SMTP host {1} port {2}." -f $to.ToString(), $client.Host, $client.Port
Try {
$client.Send($message)
"Message to: {0}, from: {1} has been successfully sent" -f $from, $to
}
Catch {
"Exception caught in CreateTestMessage: {0}" -f $Error[0]
}

Tuesday, 18 November 2008

Get-AssemblyVersion.ps1

<#
.SYNOPSIS
    Gets the version number for an assembly
.DESCRIPTION
    
.NOTES
    File Name  : Get-AssemblyVersion.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V4
.LINK
    http://pshscripts.blogspot.co.uk/2008/07/get-assemblyversionps1.html 
.EXAMPLE
    PSH [C:\foo]: .\Get-AssemblyVersion.ps1'
    Assembly: System.Speech has version number of: 4.0.0.0    
#>

# Start of script

# Define the assembly we want to load - a random reference assembly from SDK 3.0
$Pshfile = "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\system.speech.dll"

# Now load the assembly
$Myasm = [System.Reflection.Assembly]::Loadfile($Pshfile)

# Get name, version and display the results
$Aname = $Myasm.GetName()
$Aver =  $Aname.version

# Display results
"Assembly: {0} has version number of: {1}" -f $Aname.name, $aver
# End of script