Skip to content

Instantly share code, notes, and snippets.

@NateLehman
Last active July 29, 2020 12:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NateLehman/5c2d0eec03afbb5bc090a5380b17b332 to your computer and use it in GitHub Desktop.
Save NateLehman/5c2d0eec03afbb5bc090a5380b17b332 to your computer and use it in GitHub Desktop.
F# PowerShell Module Scaffold
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