I am new to Powershell and am working on setting up the profile.ps1 file. I have several managed DLLs that I often use to maintain processes throughout the day that I would like to have to load quick function calls. So I created this function in ps1 file:
function LoadSomeDll
{
[System.Reflect.Assembly]::LoadFrom("c:\wherever\SomeLib.dll")
return new-object "SomeLib.SomeObject"
}
Then, in Powershell, I do this:
PS > $myLibInstance = LoadSomeDll
The problem is that $ myLibInstance, although it seems to be loaded, does not behave as I expect, or if it will explicitly load it without a function. Say SomeLib.SomeObject has a public string property "ConnectionString" that loads itself (from the registry, yuck) when the object is constructed.
PS > $myLibInstance.ConnectionString
//Nothing returned
But, if I do this without a function, like this:
PS > [System.Reflect.Assembly]::LoadFrom("c:\wherever\SomeLib.dll")
PS > $myOtherLibInstance = new-object "SomeLib.SomeObject"
I get this:
PS > $myOtherLibInstance.ConnectionString
StringValueOfConnectionStringProperty
? Powershell?
.