Last active
July 29, 2020 12:48
-
-
Save NateLehman/5c2d0eec03afbb5bc090a5380b17b332 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