Connect-VIServer cmdlet cannot be executed when PowerShell's LanguageMode is ConstrainedLanguage
search cancel

Connect-VIServer cmdlet cannot be executed when PowerShell's LanguageMode is ConstrainedLanguage

book

Article ID: 418702

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

When PowerShell's LanguageMode is ConstrainedLanguage, if you execute Connect-VIServer cmdlet you can see similar to the following error.

PS C:\Users\Administrator> $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
PS C:\Users\Administrator> $ExecutionContext.SessionState.LanguageMode
ConstrainedLanguage
PS C:\Users\Administrator> Connect-VIServer -Server ###.###.###.###
Connect-VIServer : Specified method is not supported.
At line:1 char:1
+ Connect-VIServer -Server ###.###.###.###
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotImplemented: (:) [Connect-VIServer], PSNotSupportedException
    + FullyQualifiedErrorId : NotSupported,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

Environment

PowerCLI
VMware vCenter Server 8.x
VMware vCenter Server 7.x
VMware vSphere ESXi 8.x
VMware vSphere ESXi 7.x

Cause

ConstrainedLanguage causes an error because it lacks execution permissions in the internal processing of PowerShell when Connect-VIServer cmdlet be executed.

Resolution

This error can be avoided by using Connect-VIServer's parameter -NotDefault.

In PowerShell, as shown below the steps, store the result of specifying -NotDefault parameter with Connect-VIServer cmdlet in a variable, and then specify that variable using the -Server parameter each time you execute a cmdlet.

Steps:
1. Store the result of specifying -NotDefault parameter with Connect-VIServer cmdlet in a variable as shown below.

     $conn = Connect-VIServer -Server <IP address> -NotDefault

     * Enter your username and password as needed.

2. When executing the PowerCLI cmdlet as shown below, specify the variable in Step 1 using the -Server parameter.

     Get-VM -Server $conn

Additional Information

Japanese Version:
PowerShell の LanguageMode が ConstrainedLanguage の場合に Connect-VIServer コマンドレットが実行不可となる