New Object: The term "New Object" is not recognized as the name of the cmdlet

I want to configure a high-trust application for an application developer in SharePoint, and for this I need to first insert some commands into the PowerShell editor, for example:

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

I use Windows PowerShell in Windows Server 2012 R2, which includes Windows PowerShell 4, which by default includes the cmd-let command of a new object ... I don’t understand why my operating system does not recognize this command ... I do not stop having the following error: New-Object: the term "New-Object" is not recognized as the name of the cmdlet.

When I open PowerShell, I get this:

* select:

  The term “Select-Object” is not recognized as a cmdlet name, function, script file, or a working program. Check the spelling of the name or, if the path was included, make sure the path is correct and try again. In C: \ Program Files \ Common Files \ Microsoft Shared \ Web Server Extensions \ 15 \ CONFIG \ POWERSHELL \ Registration \ SharePoint.ps1: 1 character: 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 the cmdlet, function, script file or a workable program. Check the spelling of the name or, if the path was included, make sure the path is correct and try again in 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: "New-Object" , , . , , , . : 1 : 16 + $ certificate = New-Object System.Security.Cryptography.X509Certificates.X509Cert... + ~~~~~~~~~~     + CategoryInfo: ObjectNotFound: (New-Object: String) [], CommandN otFoundException     + FullyQualifiedErrorId: CommandNotFoundException

PS: , enter-psSession , new-object , sharepoint ( Get-SPAuthenticationRealm) ... , .

+6
3

, PowerShell . New-Object Microsoft.PowerShell.Utility, Core PowerShell PowerShell.

+3

, PSModulesPath PowerShell Modules.

$PSModulePath = Get-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath"

$newPSModulePath = $PSModulePath.PSModulePath + ";C:\Windows\System32\WindowsPowerShell\v1.0\Modules"

Set-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath" -value $newPSModulePath
+1

Nothing has been tested here, but I hypothesize that Powershell encountered a runtime error that caused it to be corrupted.

-2
source

Source: https://habr.com/ru/post/1547186/


All Articles