Skip to content

Instantly share code, notes, and snippets.

@guitarrapc guitarrapc/TestModule.psm1
Last active Dec 25, 2015

Embed
What would you like to do?
Copy dll and Import-Module copied dll
# Find Module Path
$moduleName = "TestModule";
$dllName = "$moduleName.dll";
$cachePath = Join-Path $env:TMP "__cache\$moduleName";
$tempPath = Join-Path $cachePath ([guid]::NewGuid().ToString());
if (Test-Path ".\$dllName")
{
$directory = Split-Path (Resolve-Path ".\$dllName").Path -Parent;
Copy-Item -Path $directory -Destination $tempPath -Force -Recurse;
$path = Join-Path $tempPath $dllName;
}
else
{
$moduleRoot = (Get-Module -ListAvailable -Name $moduleName).ModuleBase;
Copy-Item -Path $moduleRoot -Destination $tempPath -Force -Recurse;
$path = Join-Path $tempPath $dllName;
}
# Import as DyanmicModule
$module = Import-Module $path -PassThru
Export-ModuleMember -Variable * -Cmdlet *;
@guitarrapc

This comment has been minimized.

Copy link
Owner Author

guitarrapc commented Dec 25, 2015

animation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.