Error: "The term 'connect-VIServer' is not recognized" when attempting to connect to vCenter Server via PowerCLI
search cancel

Error: "The term 'connect-VIServer' is not recognized" when attempting to connect to vCenter Server via PowerCLI

book

Article ID: 454298

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

  • When attempting to connect to a vCenter Server using the VMware PowerCLI module, the connection fails and the following error is received:
    connect-VIServer -Server <vCenter_Server FQDN>
    connect-VIServer: The term 'connect-VIServer' is not recognized as a name of a cmdlet, function, script file, or executable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again
  • Running Get-Module -Name VCF.PowerCLI -ListAvailable shows that the module manifest is located within a nested directory (e.g., C:\Program Files\WindowsPowerShell\Modules\VCF-PowerCLI-9.1.0-25380678).

Environment

VMware vCenter Server
VCF PowerCLI

Cause

This issue occurs when the offline PowerCLI .zip file is extracted into a parent subfolder instead of being placed directly into the standard PowerShell Modules directory.

Windows PowerShell requires individual module folders to sit directly inside a path defined in the $env:PSModulePath variable. Because the module folders were nested inside a parent extraction folder (e.g., VCF-PowerCLI-9.1.0-25380678), PowerShell's auto-discovery mechanism could not locate the cmdlets, preventing the modules from finding their respective dependencies during import.

Resolution

To resolve this issue, the module folders must be moved to the correct directory level so PowerShell can properly index them.

  1. Extract the original VCF PowerCLI .zip file to a temporary location on the Machine.
  2. Open the extracted folder and copy all of the individual VMware module folders inside it.
  3. Paste all of the copied folders directly into the root of the PowerShell modules path: C:\Program Files\WindowsPowerShell\Modules\.
  4. Launch a new PowerShell session to refresh the module paths.
  5. Run the connection command again to verify the functionality:
    Connect-VIServer -Server <vCenter_FQDN>

Additional Information

Connect-VIServer
Connect to a vCenter Server System