- #
- .SYNOPSIS
- This script demonstrates the Assembly.GetType method.
- .DESCRIPTION
- This script creates an int32, then calls into .NET to find
- the assembly that the int32 class comes from. The assembly
- details are then output. This script is a re-work of an MSDN
- code sample.
- .NOTES
- File Name : Get-AssemblyDetails.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN Sample posted at:
- http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getassembly.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-AssemblyDetails.ps1'
- CodeBase=: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
- #>
- # Set the Type instance to the target class type.
- $Integer1 = New-Object System.Int32
- $Type1 = $Integer1.GetType();
- # Instantiate an Assembly class to the assembly housing the Integer type.
- $SampleAssembly = [System.Reflection.Assembly]::GetAssembly($Integer1.GetType())
- # Gets the location of the assembly using file: protocol.
- "CodeBase=: {0}" -f $SampleAssembly.CodeBase
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Showing posts with label system.reflection.assembly. Show all posts
Showing posts with label system.reflection.assembly. Show all posts
Wednesday, 14 July 2010
Get-AssemblyDetails.ps1
Labels:
code,
powershell,
PowerShell scripts,
Script,
system.reflection.assembly
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
Labels:
loadfile,
powershell,
system.reflection.assembly
Monday, 17 November 2008
Get-AssemblyName.ps1
<#
.SYNOPSIS
Gets assembly full name of a loaded assembly
.DESCRIPTION
This script uses reflection to get and assembly, then
gets the assembly's full name
.NOTES
File Name : Get-AssemblyName.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2 CTP3
.LINK
http://pshscripts.blogspot.co.uk/2008/11/get-assemblynameps1.html
.EXAMPLE
PSH [C:\foo]: .\Get-AssemblyName.Ps1'
Full name = "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
#>
# Start of script
# Using Reflection to get information from an Assembly:
$o =[System.Reflection.Assembly]::Load("mscorlib.dll")
$name = $o.GetName()
# Display full name
"Full name = `"{0}`"" -f $name
# End of script
Wednesday, 30 July 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 V2 CTP3 .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: 3.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
Labels:
loadfile,
powershell,
scripts,
system.reflection.assembly
Subscribe to:
Posts (Atom)