Cannot get scripts to run in PowerShell
-
09-10-2020 - |
Frage
We installed SharePoint 2010 on Server 2012.
I am trying to install FBA, but cannot get the deploy script to run.
First I switch to PowerShell 2.0 doing the following:
Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.
PS C:\Users\sp_farm> powershell.exe -version 2
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS C:\Users\sp_farm> $psversiontable
Name Value
---- -----
CLRVersion 2.0.50727.8000
BuildVersion 6.1.7601.18606
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
PS C:\Users\sp_farm> [Environment]::Version
Major Minor Build Revision
----- ----- ----- --------
2 0 50727 8000
Then navigate to the installation directory:
PS C:\Users\sp_farm> cd\
PS C:\> cd '.\install files'
PS C:\install files> cd .\2010FBAPack
Allow Scripts to Deploy:
PS C:\install files\2010FBAPack> Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Deploy FBA Script
PS C:\install files\2010FBAPack> .\deploy
The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.
Get-SPSolution : Microsoft SharePoint is not supported with version 4.0.30319.34014 of the Microsoft .Net Runtime.
At C:\install files\2010FBAPack\UnDeploy.ps1:40 char:18
+ $featureExists = Get-SPSolution $solutionName -ErrorAction SilentlyContinue
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share...dletGetSolution:SPCmdletGetSolution) [Get-SPSolution], PlatformNotSupportedException + FullyQualifiedErrorId :Microsoft.SharePoint.PowerShell.SPCmdletGetSolution
Solution not installed
restart-service : Service 'SharePoint 2010 Timer (SPTimerV4)' cannot be stopped due to the following error: Cannot open
SPTimerV4 service on computer '.'.
At C:\install files\2010FBAPack\Deploy.ps1:58 char:16 restart-service <<<< SPTimerV4 + CategoryInfo : CloseError:(System.ServiceProcess.ServiceController:ServiceController) [Restart-Service], ServiceCommandException+ FullyQualifiedErrorId : CouldNotStopService,Microsoft.PowerShell.Commands.RestartServiceCommand
Going to add solution
Add-SPSolution : Access denied.
At C:\install files\2010FBAPack\Deploy.ps1:63 char:15
+ Add-SPSolution <<<< $solutionPath+ CategoryInfo : InvalidData:(Microsoft.Share...dletAddSolution:SPCmdletAddSolution) [Add-SPSolution], SecurityException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletAddSolution
Going to install solution to all web applications
Install-SPSolution : This solution contains resources scoped for a Web application and must be deployed to one or more Web applications.
At C:\install files\2010FBAPack\Deploy.ps1:66 char:19
+ Install-SPSolution <<<< –identity $solutionName –allwebapplications–GACDeployment + CategoryInfo : InvalidData: (Microsoft.Share...InstallSolution:SPCmdletInstallSolution) [Install-SPSolution], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletInstallSolution
Waiting for job to finish
Timer job not found
The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.
restart-service : Service 'SharePoint 2010 Timer (SPTimerV4)' cannot be stopped due to the following error: Cannot open SPTimerV4 service on computer '.'.
At C:\install files\2010FBAPack\Activate.ps1:21 char:1
+ restart-service SPTimerV4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~ +
CategoryInfo : CloseError:(System.ServiceProcess.ServiceController:ServiceController) [Restart-Service], ServiceCommandException + FullyQualifiedErrorId : CouldNotStopService,Microsoft.PowerShell.Commands.RestartServiceCommand
Deactivating/activating active features to ensure activation script is run Get-SPFeature : Microsoft SharePoint is not supported with version 4.0.30319.34014 of the Microsoft .Net Runtime. At C:\install files\2010FBAPack\Activate.ps1:3 char:13
+ $feature = Get-SPFeature $featureName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share...mdletGetFeature:SPCmdletGetFeature) [Get-SPFeature], PlatformNotSupportedException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetFeature
You cannot call a method on a null-valued expression.
At C:\install files\2010FBAPack\Activate.ps1:4 char:2
+ $features =[Microsoft.SharePoint.Administration.SPWebService]::ContentService. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
PS C:\install files\2010FBAPack> '
>>
I checked Shell access permissions and think everything is setup correctly.
Now I am at a loss of what to do. Any help would be appreciated.
Thanks.
Lösung 2
The solution I found was to simply enter the commands in PowerShell line by line instead of using the script provided with the FBA Pack. I don't know why the script wasn't running, but I can install without using the script.
Indeed you need to be in version 2.0, but with the last version of SharePoint Server 2010 which has to be used with slipstream when running SharePoint 2010 on Server 2012 already has the SharePoint PowerShell pointing at version 2.0.
Andere Tipps
There is a known compatibility issue with SharePoint 2010 and Windows Management Framework 4.0 (WMF), which also includes PowerShell 3.0. If you install these components on a server that also runs SharePoint 2010, you may encounter errors when running SharePoint PowerShell cmdlets.
Please check below article for resolution of your issue.
WORKAROUND Mentioned on MSDN
To work around this issue, change the Target field value for SharePoint 2010 Management Shell. To do this, follow these steps:
Click Start, and then right-click SharePoint 2010 Management Shell.
Click Properties.
Click the Shortcut tab in the SharePoint 2010 Management Shell Properties window.
Input the following value in the Target field:
Command
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "