PowerShell,术语 'xxxxxx' 未被识别为 cmdlet 的名称

PowerShell, The term 'xxxxxx' is not recognized as the name of a cmdlet

所以我有以下 PowerShell 脚本,它在名为 M-Files 的程序中安装第三方插件。 这个脚本几天前运行完美,然后我今天尝试 运行 它而不做任何更改,它给了我一些错误,如下所示。

我是新手,所以我做了一些研究,但没有找到任何有用的东西..

仅供参考: 尝试 解决方案但没有帮助,我没有 PowerShell 处理器 运行ning 所以我没有达到任何限制。

脚本:

# Application details
$appFilePath = "bin\Debug\ACV.mfappx"
$appGuid = "e9982d4b-e705-4016-a99c-dfd4bbe3fadc"

# Target vault
$vaultName = "IDIRMEGA"

# Connection details 
$authType = 1 # 1 = MFAuthTypeLoggedOnWindowsUser
$userName = ""
$password = ""
$domain = ""
$spn = ""
$protocolSequence = "ncacn_ip_tcp"
$networkAddress = "localhost"
$endpoint = 2266
$encryptedConnection = $false
$localComputerName = ""

Write-Host "Connecting to Vault..."

# Load M-Files API
$null = [System.Reflection.Assembly]::LoadWithPartialName("Interop.MFilesAPI")

# Connect to M-Files Server
$server = new-object MFilesAPI.MFilesServerApplicationClass
$tzi = new-object MFilesAPI.TimeZoneInformationClass
$tzi.LoadWithCurrentTimeZone()
$null = $server.ConnectAdministrativeEx( $tzi, $authType, $userName, $password, $domain, $spn, $protocolSequence, $networkAddress, $endpoint, $encryptedConnection, $localComputerName )

# Get the target vault
$vaultOnServer = $server.GetOnlineVaults().GetVaultByName( $vaultName )

# Login to vault
$vault = $vaultOnServer.LogIn()

# Try to uninstall existing application
try
{
    Write-Host "Checking for previous installation of ACV..."

    # Uninstall
    $vault.CustomApplicationManagementOperations.UninstallCustomApplication( $appGuid );

    Write-Host "Restarting after uninstall..."

    # Restart vault. The installation seems to fail, if the vault is not restarted after uninstall.
    $server.VaultManagementOperations.TakeVaultOffline( $vaultOnServer.GUID, $true )
    $server.VaultManagementOperations.BringVaultOnline( $vaultOnServer.GUID )

    # Login to vault again.
    $vault = $vaultOnServer.LogIn()
}
catch {}

Write-Host "Installing ACV..."

# Install application. The vault should not have the application installed at this point.
$vault.CustomApplicationManagementOperations.InstallCustomApplication( $appFilePath )

Write-Host "Restarting after install..."

# Restart vault
$server.VaultManagementOperations.TakeVaultOffline( $vaultOnServer.GUID, $true )
$server.VaultManagementOperations.BringVaultOnline( $vaultOnServer.GUID )

错误:

1>  Write-Host : The term 'Write-Host' is not recognized as the name of a cmdlet, function, script file, or operable progra
1>  m. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:20 char:1
1>  + Write-Host "Connecting to Vault..."
1>  + ~~~~~~~~~~
1>      + CategoryInfo          : ObjectNotFound: (Write-Host:String) [], CommandNotFoundException
1>      + FullyQualifiedErrorId : CommandNotFoundException
1>   
1>  new-object : The term 'new-object' is not recognized as the name of a cmdlet, function, script file, or operable progra
1>  m. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:26 char:11
1>  + $server = new-object MFilesAPI.MFilesServerApplicationClass
1>  +           ~~~~~~~~~~
1>      + CategoryInfo          : ObjectNotFound: (new-object:String) [], CommandNotFoundException
1>      + FullyQualifiedErrorId : CommandNotFoundException
1>   
1>  new-object : The term 'new-object' is not recognized as the name of a cmdlet, function, script file, or operable progra
1>  m. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:27 char:8
1>  + $tzi = new-object MFilesAPI.TimeZoneInformationClass
1>  +        ~~~~~~~~~~
1>      + CategoryInfo          : ObjectNotFound: (new-object:String) [], CommandNotFoundException
1>      + FullyQualifiedErrorId : CommandNotFoundException
1>   
1>  You cannot call a method on a null-valued expression.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:28 char:1
1>  + $tzi.LoadWithCurrentTimeZone()
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
1>      + FullyQualifiedErrorId : InvokeMethodOnNull
1>   
1>  You cannot call a method on a null-valued expression.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:29 char:1
1>  + $null = $server.ConnectAdministrativeEx( $tzi, $authType, $userName,  ...
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
1>      + FullyQualifiedErrorId : InvokeMethodOnNull
1>   
1>  You cannot call a method on a null-valued expression.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:32 char:1
1>  + $vaultOnServer = $server.GetOnlineVaults().GetVaultByName( $vaultName ...
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
1>      + FullyQualifiedErrorId : InvokeMethodOnNull
1>   
1>  You cannot call a method on a null-valued expression.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:35 char:1
1>  + $vault = $vaultOnServer.LogIn()
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
1>      + FullyQualifiedErrorId : InvokeMethodOnNull
1>   
1>  Write-Host : The term 'Write-Host' is not recognized as the name of a cmdlet, function, script file, or operable progra
1>  m. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:56 char:1
1>  + Write-Host "Installing ACV..."
1>  + ~~~~~~~~~~
1>      + CategoryInfo          : ObjectNotFound: (Write-Host:String) [], CommandNotFoundException
1>      + FullyQualifiedErrorId : CommandNotFoundException
1>   
1>  You cannot call a method on a null-valued expression.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:59 char:1
1>  + $vault.CustomApplicationManagementOperations.InstallCustomApplication ...
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
1>      + FullyQualifiedErrorId : InvokeMethodOnNull
1>   
1>  Write-Host : The term 'Write-Host' is not recognized as the name of a cmdlet, function, script file, or operable progra
1>  m. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:61 char:1
1>  + Write-Host "Restarting after install..."
1>  + ~~~~~~~~~~
1>      + CategoryInfo          : ObjectNotFound: (Write-Host:String) [], CommandNotFoundException
1>      + FullyQualifiedErrorId : CommandNotFoundException
1>   
1>  You cannot call a method on a null-valued expression.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:64 char:1
1>  + $server.VaultManagementOperations.TakeVaultOffline( $vaultOnServer.GU ...
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
1>      + FullyQualifiedErrorId : InvokeMethodOnNull
1>   
1>  You cannot call a method on a null-valued expression.
1>  At C:\Users\Konica Minolta\source\repos\ACV\ACV\install-application.ps1:65 char:1
1>  + $server.VaultManagementOperations.BringVaultOnline( $vaultOnServer.GU ...
1>  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
1>      + FullyQualifiedErrorId : InvokeMethodOnNull
1>   
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

喜欢包含模块的问题检查路径的最佳使用:

1) 在 powershell cli 或 ISE 中检查 $env:psmodulePath 它必须包含模块目录的路径(如果它为空则必须添加路径)

2)对于不finded/loading自动使用Import-Module cmdlet

的手动加载模块

3)您可以配置您的 psprofile 来加载它 config_psprofile