-
-
Save evanricard/915e98b6a1b11fce31ef8fbddcc8db9d to your computer and use it in GitHub Desktop.
F# PowerShell Module Scaffold
This file contains 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
dotnet new sln -o DotnetCoreProj | |
cd DotnetCoreProj | |
dotnet new classlib -lang 'F#' -o src/MyPSModule | |
dotnet sln add src/MyPSModule/MyPSModule.fsproj | |
cd src/MyPSModule | |
dotnet add package PowerShellStandard.Library | |
@' | |
namespace MyPSModule | |
open System.Management.Automation | |
[<Cmdlet("Get", "Foo")>] | |
type GetFooCommand () = | |
inherit PSCmdlet () | |
[<Parameter>] | |
member val Name : string = "" with get, set | |
override x.EndProcessing () = | |
x.WriteObject ("Foo is " + x.Name) | |
base.EndProcessing () | |
'@ | Out-File Library.fs -Encoding UTF8 | |
dotnet build | |
dotnet publish | |
Import-Module ./bin/Debug/netstandard2.0/publish/MyPSModule.dll | |
Get-Foo -Name Bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment