gpt4 book ai didi

powershell - 新对象 : The term New-Object is not recognized as the name of a cmdlet

转载 作者:行者123 更新时间:2023-12-02 05:09:40 26 4
gpt4 key购买 nike

我想为 SharePoint 中的应用程序开发配置高可信应用程序,为此,我需要首先在 powershell 编辑器中插入一些命令,例如:

$publicCertPath = "C:\Certs\HighTrustSampleCert.cer" 
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($publicCertPath)

我在 Windows Server 2012 R2 上使用 Windows PowerShell,其中包括 Windows PowerShell 4,默认情况下包括 new-object cmd-let...但我不明白,为什么我的操作系统无法识别该命令。 ..我不断出现以下错误:New-Object:术语“New-Object”未被识别为 cmdlet 的名称。

当我打开 powerShell 时,我得到这个:

*select :

The term 'Select-Object' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:1 char:16 + $ver = $host | select version + ~~~~~~ + CategoryInfo : ObjectNotFound: (Select-Object:String) [], Comma ndNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Set-location : The term 'Set-location' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again At C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:4 char:1 + Set-location $home + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-location:String) [], Comman dNotFoundException + FullyQualifiedErrorId : CommandNotFoundException*

直到今天我都认为这是正常的...这与错误有什么关系吗?这是洞(新对象)异常堆栈:

New-Object : The term 'New-Object' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:16 + $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Cert ... + ~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (New-Object:String) [], CommandN otFoundException + FullyQualifiedErrorId : CommandNotFoundException

ps:我想提一下,当我使用 Enter-psSession 并远程工作时,命令 new-object 被识别,但共享点命令(如 Get-SPAuthenticationRealm)不再被识别......这就像有一个问题与操作系统有关。

最佳答案

您的 PowerShell 安装似乎已损坏,需要修复。 New-Object cmdlet 由 Microsoft.PowerShell.Utility 模块导出,该模块是核心 PowerShell 模块之一,默认情况下应在所有 PowerShell 安装上导入。

关于powershell - 新对象 : The term New-Object is not recognized as the name of a cmdlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24576990/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com