Private/Confirm-PoSHModuleAvailabliy.ps1
|
function Confirm-PoSHModuleAvailabliy { Param([string]$PSModule) $CurrentFunction = Get-FunctionName Write-Log -Message "### Start Function $CurrentFunction ###" $StartRunTime = (Get-Date).ToString($Script:DateFormatLog) #################### main code | out- host ##################### [string] $result = "passed" If ($null -eq (Get-Module -ListAvailable -Name $PSModule)) { Invoke-Output -T Error -M "The '$PSModule' PowerShell module is not installed." $result = "failed" } else { Import-Module $PSModule Invoke-Output -T Bullet -M "Imported PowerShell module: " -TM $PSModule } ######################## main code ############################ $runtime = Get-RunTime -StartRunTime $StartRunTime Write-Log -Message " Run Time: $runtime [h] ###" Write-Log -Message "### End Function $CurrentFunction ###" return $result } |