vCheck-vSphere icon indicating copy to clipboard operation
vCheck-vSphere copied to clipboard

Suggest vCheck.ps1 check for required modules

Open monahancj opened this issue 6 years ago • 0 comments

I keep my environment stripped down to only what's required so I don't use the wrong cmdlet of the same name from a different module and so that Intellisense runs faster. When I ran into many errors in "00 Connection Plugin for vCenter.ps1" it was because the module CimCmdlets wasn't loaded. It may also explain while running vCheck.ps1 for the first time I didn't get the interview of configuration questions.

Putting this code early in vCheck.ps1, immediately after the variables declaration, would occasionally save some people some time.

PS O:\temp> $RequiredModules = "CimCmdlets","VMware.VimAutomation.Common", "breakit"
PS O:\temp> $RequiredModules | ForEach-Object {
>> if (-not (Get-Module -Name $_)) { Write-Error "$(Get-Date)- *** Module $($_) not available."; break }
>> }
$RequiredModules | ForEach-Object {
if (-not (Get-Module -Name $_)) { Write-Error "$(Get-Date)- *** Module $($_) not available."; break }
} : 01/08/2019 11:54:23- *** Module breakit not available.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

monahancj avatar Jan 08 '19 17:01 monahancj