Closed chkeita closed 8 years ago
It is not possible now, but definitely nice to have feature. @kcheick Do you want to implement this?
I gave it a stab today and made little progress but it is not really working right now. It turns out that ytou can pass a path to powershell module file just like i did but the problem here is that the module is being imported under the restricted execution policy which prevents the script from being executed. I was able to get around it by setting the AuthorizationManager in HostedRuntime.fs like so :
let initState = InitialSessionState.CreateDefault()
initState.AuthorizationManager <- new Microsoft.PowerShell.PSAuthorizationManager("Microsoft.PowerShell")
this allows me to list the function in the module but when i call it it returns null no matter what. Now i am stuck, any pointer on what is happening here would be appreciated.
for reference here is my test module
function DoSomething{
param ([string] $test)
$test
}
export-moduleMember -function DoSomething
and the the testing code
type TestProv = PowerShellProvider< @"testModule.psm1">
TestProv.DoSomething (test="testData") // intellisense works for the method name and parameters
|> printfn "%A"
// prints : <null>
The powershell function was missing an output type Here is the PR
function doSomething {
[OutputType([string])]
param (
[string] $test
)
return $test
}
export-moduleMember -function doSomething
Released in v0.3.1
i am trying to to use the type provider on some existing powershell scripts without much success. I was wondering if that feature is supported. if so what is the syntax to do it? Here is an example of i tried so far :