Skip to content

Instantly share code, notes, and snippets.

@evanricard
Forked from NateLehman/AllInOne.ps1
Created July 5, 2020 20:32
Show Gist options
  • Save evanricard/915e98b6a1b11fce31ef8fbddcc8db9d to your computer and use it in GitHub Desktop.
Save evanricard/915e98b6a1b11fce31ef8fbddcc8db9d 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