Richard Siddaways postif(([appdomain]::currentdomain.getassemblies() | Where{$_ -match "System.Drawing"}) -eq $null){Write-Verbose "Loading System.Drawing assembly.";[Void] [System.Reflection.Assembly]::LoadFromPartialName("System.Drawing");}
Assemblies loaded in PowerShellgot me thinking in this direction. All I did was add the wrapper to test for a specific item. This could easily be modularized into a function:
function Load-Assembly{[CmdletBinding()]param([Parameter(Mandatory = $true,ValueFromPipeline = $true)][ValidateNotNullOrEmpty()][String]$AssemblyName,[Switch]$Report = $false)
if(([appdomain]::currentdomain.getassemblies() | Where {$_ -match $AssemblyName}) -eq $null)
{
if($Report) {
Write-Output "Loading $AssemblyName assembly.";
}
[Void] [System.Reflection.Assembly]::LoadFromPartialName($AssemblyName);
return 1
}
else
{
if($Report) {
Write-Output "$AssemblyName is already loaded.";
}
return -1
}
}
Load-Assembly -AssemblyName System.Drawing