How it is possible to call a function from a other PowerShell script an returning the object?
Main Script:
# Run function script
. C:\MySystem\Functions.ps1
RunIE
$ie.Navigate("http://www.stackoverflow.com")
# The Object $ie is not existing
Functions Script:
function RunIE($ie)
{
$ie = New-Object -ComObject InternetExplorer.Application
}
Just “output” the object from the function like so:
or more idiomatically
Then assign the output to a variable in your main script: