Public/New-PsModule.ps1

function New-PsModule {
  [CmdletBinding()]
  param (
    [string]$path
  )
  
  # $path = (Get-IfNull $path (Get-Location));
  $path = Get-Answer "Enter project folder without module name" (Get-IfNull $path (Get-Location)) -AnswerRequired
  $moduleName = Get-Answer "Enter module name" -AnswerRequired
  
  $modulePath = Join-Path $path $moduleName;
  if (Test-Path $modulePath) {
    Write-Warning "Path already exists"

    if (Get-JaNein "Delete existing folder?" "n") {
      Remove-Item $modulePath -Recurse
    }
    else {
      Write-Error "Vorgang abgebrochen.";
      break;
    }
  }


  $author = Get-Answer "Enter author" "Peter Ullrich"
  $companyName = Get-Answer "Enter company name" "dotup IT solutions"
  $year = (Get-Date).Year;
  $copyright = Get-Answer "Enter author" "Copyright (c) $year $companyName, $author"
  $description = Get-Answer "Enter description" ""
  # Create directories

  New-Item -ItemType Directory -Force -path  $path\$moduleName

  New-Item -ItemType Directory -Force -path  $path\$moduleName\Private

  New-Item -ItemType Directory -Force -path  $path\$moduleName\Public

  New-Item -ItemType Directory -Force -path  $path\$moduleName\de-DE # For about_Help files

  New-Item -ItemType Directory -Force -path  $path\$moduleName\Tests

  #Create files

  New-Item "$path\$moduleName\publish.ps1" -ItemType File

  Set-Content -Path "$path\$moduleName\publish.ps1" -Value '
Clear-Host
 
$path = ".";
 
$functions = Get-PsModuleFunctions $path -PublicOnly
 
Update-ModuleManifest -FunctionsToExport $functions;
$PowershellApiKey = "EnterYourPowershellApiKey";
 
Publish-Module -Path $path -NugetAPIKey $PowershellApiKey;'


  New-Item "$path\$moduleName\$moduleName.psm1" -ItemType File
  Set-Content -Path "$path\$moduleName\$moduleName.psm1" -Value '$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue )
 
#Dot source the files
Foreach ($import in @($Public + $Private)) {
  Try {
    . $import.fullname
  }
  Catch {
    Write-Error -Message "Failed to import function $($import.fullname): $_"
  }
}
 
Export-ModuleMember -Function $Public.Basename'


  New-Item "$path\$moduleName\$moduleName.Format.ps1xml" -ItemType File

  New-Item "$path\$moduleName\de-DE\about_$moduleName.help.txt" -ItemType File

  New-Item "$path\$moduleName\Tests\$moduleName.Tests.ps1" -ItemType File

  New-ModuleManifest -path $path\$moduleName\$moduleName.psd1 `
    -RootModule "$moduleName.psm1" `
    -Description $Description `
    -PowerShellVersion 3.0 `
    -Author $Author `
    -CompanyName $companyName `
    -Copyright $copyright `
    -FunctionsToExport '*' `
    -CmdletsToExport '*' `
    -FormatsToProcess "$moduleName.Format.ps1xml"

}