DotupPsEssentials.psm1
<#PSScriptInfo .VERSION 1.0.0 .GUID 9731b8cb-beee-4c9c-9296-8e0037fd2dbf .AUTHOR Peter Ullrich .COMPANYNAME dotup IT solutions .COPYRIGHT copyright @2019 dotup IT solutions, Peter Ullrich .TAGS DotupPsEssentials .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES 1.0: Get-Answer .DESCRIPTION Basic PowerShell functions #> function Get-Answer{ Param( [Parameter(Mandatory = $true)] [string]$Question, [string]$DefaultAnswer, [switch]$AnswerRequired ) if ($DefaultAnswer) { $Question = "$($Question) ($($DefaultAnswer))"; } $value = Read-Host $Question; if (-Not $value) { $value = $DefaultAnswer; } if ((-Not $value) -and $AnswerRequired) { Write-Error "Error: Required parameter is empty"; break; } $value; } Export-ModuleMember -Function Get-Answer; |