Demo-Module.ps1
<#PSScriptInfo .VERSION 1.0.0 .GUID e5d2388d-1bb3-4185-b2ce-e48027ef05ff .AUTHOR Frits van Drie (3-Link.nl) .COMPANYNAME 3-Link Opleidingen .COPYRIGHT free to use and distribute without modifications .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES .PRIVATEDATA #> <# .DESCRIPTION Developed by 3-Link Opleidingen for training purposes only #> Param() # Filename: Demo-Module.ps1 # Author : Frits van Drie (3-Link.nl) # Date : 2022-04-07 # https://powershellexplained.com/2017-05-27-Powershell-module-building-basics/ $moduleName = "DoSomething" # Install-Module $moduleFile = "$moduleName.psm1" $modulePath = $env:PSModulePath.split(';')[0] $moduleFilePath = Join-Path $modulePath "$moduleName\$moduleFile" New-Item -Name $moduleName -Path $modulePath -ItemType Directory -ErrorAction Stop @" Function Do-This { [cmdletbinding()] PARAM() Write-Verbose "I'm going to do this" Write-Host "I do This!" Write-Verbose "I have done This" } Function Do-That { Write-Host "Have done That!" } Function Do-Such { Write-Host "Thats the way I did it!" } Export-ModuleMember "*" # -Function "Do-This" "@ | Out-File $moduleFilePath BREAK # View Module ise $moduleFilePath # Demo Module Get-Module $moduleName -ListAvailable Import-Module $moduleName -Force Get-Command -Module $moduleName Do-Such Do-This Do-This -Verbose |