Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Test-PowerCLI
- {
- [CmdletBinding()]
- [OutputType([boolean])]
- Param
- (
- # If PowerCLI isn't loaded, loads PowerCLI. Will throw error if it can't load.
- [Parameter(Position=0)]
- [Switch] $LoadIfFalse
- )
- Process
- {
- if(get-command connect-viserver -ErrorAction SilentlyContinue)
- {
- return $true
- } elseif ($LoadIfFalse)
- {
- Write-Verbose "PowerCLI check failed, attempting to load PowerCLI"
- add-pssnapin VMWare.vimautomation.core
- if ($?)
- {
- return $true
- } else {
- write-error "PowerCLI could not be loaded. Check your PowerCLI installation."
- return $false
- }
- } else {return $false }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement