Install up-to-date PowerShell Core.
$brew cask install powershell
...
$ pwsh --version
PowerShell v6.0.2
$
Install PSModule template.
dotnet new -i Microsoft.PowerShell.Standard.Module.Template
dotnet new psmodule
dotnet build
The module is ready. Let's use it in pwsh.
pwsh
PS > Import-Module ./bin/Debug/netstandard2.0/PS.dll
PS > (Get-Module PS).ExportedCmdlets
PS > Test-SampleCmdlet(1)
Done.