To use ‘Connect-VIServer’ cmdlet in your PowerShell script. You have to follow two steps:
1) Install VMware PowerCLI in your machine. It will register itself in PowerShell during the installation.
2) Use ‘Add-PSSnapIn VMware.VimAutomation.Core’ to add the registered PowerShell VMware Snapin to the current session.