Powershell - Checking the Language Mode

For security purposes, it is possible to control the language mode in a given Powershell session. These language modes can constrict which modules can be loaded during the life of a powershell session.

Learn mode about Powershell langeuage modes: About Language Modes – Microsoft

Detect the Current Language Mode

$sLangMode = $ExecutionContext.SessionState.LanguageMode
If ($sLangMode -ne “FullLanguage”){
Write-Host ” !! Unable to run scrit – Powershell Using Wrong Language Mode !! ”

Try putting this simple statement at the start of your powershell scripts to avoid any unhandled exceptions caused by constrictive language modes.