Wednesday, February 5, 2014

Installing SharePoint 2010 with AutoSPInstaller on Windows Server 2012

The bad news;  this will not work out of the box. The good news; it’s not that hard to fix.
The issues are related to PowerShell v2 vs. v3 and .NET runtime v2 vs. v4. The catch 22 is that SharePoint commandlets requires PowerShell v2 with .NET runtime v2, while the WebAdministration commandslets in Windows Server 2012 requires PowerShell v3 and .NET runtime v4.
The error you get if you do not copy WebAdministration from a 2008 server is something like:
import-module : The 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\webadministration\webadministration.psd1' module cannot be imported because its manifest contains one or more members that are not valid. The valid manifest members
are ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'Processor
Architecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport'). Remove the members that are not valid ('HelpInfoUri')

Below I’ll underline the steps to get this working.

Step 1

Copy the folder C:\Windows\System32\WindowsPowerShell\v1.0\Modules\WebAdministration from a Windows Server 2008 R2 over to your 2012 server.

Step 2

Change line 6229(function ImportWebAdministration) in AutoSPInstallerFunctions.ps1 from

Import-Module WebAdministration

to

Import-Module –Name <path of copied folder step 1>\WebAdministration.psd1

Step 3

Edit AutoSPInstallerLaunch.bat at line 57 where you add the -version 2 parameter before –NoExit

"%SYSTEMROOT%\system32\windowspowershell\v1.0\powershell.exe" -Command Start-Process "$PSHOME\powershell.exe" -Verb RunAs -ArgumentList "'-version 2 -NoExit -ExecutionPolicy Bypass %~dp0\AutoSPInstallerMain.ps1 %InputFile%'"

Now you should be all set to get it all up and running as long as your config script is correct :-)

Other issues you may encounter

HTTPS

If you set up your sites using https, you will get an error when the code is trying to assign the certificate to your web site. This can be fixed by going to IIS Manager, click your site, click Bindings, click Edit and choose the certificate from the dropdown. In my case the *.local self-signed wildcard one.

In order to overcome this you can comment out line 2386-2401 in AutoSpInstallerFunctions.ps1 which deal with assigning the certificate to the sites.

UPA

If you opt to provision UPA/UPS more PowerShell windows will be spawned and you have to add the –version 2 line in more places. Search for powershell.exe and modify accordingly.