Created
March 9, 2014 22:58
-
-
Save hobelinm/9456238 to your computer and use it in GitHub Desktop.
Proof of concept for dynamic loading of functions made in PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Considering the test function in a given location | |
# you can ignore the following line | |
"function test{""Original Test""}" > test.ps1 | |
# This is a sample of the stub that would peform the function of | |
# finding and downloading the original function. For the sake of | |
# the test we can consider that's already done in test.ps1 in $PWD | |
function test | |
{ | |
"Stub Test" | |
# Future calls will go to the original test method and not this stub | |
Remove-Item function:test | |
# Replace this line for finding-loading-installing locally | |
Import-Module .\test.ps1 -Global | |
# Since the intended call was to the original function, call it | |
test | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment