New-Object :术语 New-Object 不被识别为 cmdlet 的名称 [英] New-Object : The term New-Object is not recognized as the name of a cmdlet

查看:61
本文介绍了New-Object :术语 New-Object 不被识别为 cmdlet 的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to configure high trusted app for app dev in SharePoint, and to do so, i need first to insert some commands in the powershell editor like :

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

我在 Windows Server 2012 R2 上使用 Windows PowerShell,其中包括默认包含新对象 cmd-let 的 Windows PowerShell 4...不过我不明白,为什么我的操作系统不能识别该命令... 我不会停止出现以下错误:新对象:术语新对象"未被识别为 cmdlet 的名称.

I am using windows PowerShell on Windows Server 2012 R2 which includes Windows PowerShell 4 that includes by default the new-object cmd-let... I don't understand though, why doesn't my operating system recognize that command ... I don't stop having the following error : New-Object : The term 'New-Object' is not recognized as the name of a cmdlet.

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

When i open powerShell i get this :

*选择:

术语Select-Object"未被识别为 cmdlet 的名称,函数、脚本文件或可运行的程序.检查拼写名称,或者如果包含路径,请验证路径是否正确并且再试一次.在 C:\Program Files\Common Files\Microsoft Shared\Web服务器扩展\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:1字符:16+ $ver = $host |选择版本+~~~~~~+ CategoryInfo : ObjectNotFound: (Select-Object:String) [], CommandNotFoundException+FullyQualifiedErrorId:CommandNotFoundException Set-location:术语Set-location"未被识别为 cmdlet 的名称,函数、脚本文件或可运行的程序.检查拼写名称,或者如果包含路径,请验证路径是否正确并且再试一次在 C:\Program Files\Common Files\Microsoft Shared\Web ServerExtensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:4 字符:1+ 设置位置 $home+ ~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (Set-location:String) [], Command dNotFoundException+ FullQualifiedErrorId : CommandNotFoundException*

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*

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

I thought that was normal until today... does it have any relation with the error? And here is the hole (new-object) exception stack:

New-Object :术语New-Object"不被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查拼写名称,或者如果包含路径,请验证路径是否为正确并重试.在行:1 字符:16+ $certificate = 新对象 System.Security.Cryptography.X509Certificates.X509Cert ...+ ~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (New-Object:String) [], CommandN otFoundException+ FullQualifiedErrorId : CommandNotFoundException

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

ps: i want to mention that when i used enter-psSession and worked remotely, the command new-object was recognized but sharepoint commands (like Get-SPAuthenticationRealm) were no more recognized ... And it's like there is a problem related to the operating system.

推荐答案

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

It appears that your PowerShell installation is corrupted and needs to be repaired. The New-Object cmdlet is exported by the Microsoft.PowerShell.Utility module, which is one of the Core PowerShell modules and should be imported by default on all PowerShell installations.

这篇关于New-Object :术语 New-Object 不被识别为 cmdlet 的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆