Here are the PowerShell scripts from the SharePoint 2013 Unleashed book:
Instructions
- Download all the scripts as ZIP file
- Run SharePoint 2013 Management Shell (as Administrator)
- Run the .\Config-Farm.ps1 script
- Follow the on-screen instructions to configure your farm
Config-Farm Script
# # SharePoint 2013 Unleashed - PowerShell farm config script # http://www.amazon.com/Microsoft-SharePoint-2013-Unleashed-Michael/dp/0672337339 # Copyright: Toni Frankola, Michael Noel # Version: 2.1, Feb 2013. # # Source: http://tinyurl.com/SP2013-Config # Licensed under the MIT License: # http://www.opensource.org/licenses/mit-license.php # $path = Get-Location $settings = Get-Content ($path.Path + "\settings.xml") -ErrorAction SilentlyContinue Function Get-SettingValue { param($Xml, [string]$XPath, [string]$Prompt, [bool]$SecureString = $false) if($Xml -ne $null -and $Xml.SelectSingleNode($XPath) -ne $null -and $Xml.SelectSingleNode($XPath).InnerXml -ne "") { return $Xml.SelectSingleNode($XPath).InnerXml } else { if($SecureString) { $value = Read-Host $Prompt -AsSecureString; } else { $value = Read-Host $Prompt; } return $value; } } Function Get-CredentialValue { param($Xml, [string]$UsernameXPath, [string]$PasswordXPath, [string]$AccountName = "", [string]$Message) if($Xml -ne $null -and $Xml.SelectSingleNode($UsernameXPath) -ne $null -and $Xml.SelectSingleNode($UsernameXPath).InnerXml -ne "" -and $Xml.SelectSingleNode($PasswordXPath) -ne $null -and $Xml.SelectSingleNode($PasswordXPath).InnerXml -ne "") { $username = $Xml.SelectSingleNode($UsernameXPath).InnerXml; $password = $Xml.SelectSingleNode($PasswordXPath).InnerXml $password = convertto-securestring $password -asplaintext -force; return new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password } else { return Get-Credential $AccountName -Message $Message } } $configType = Get-SettingValue -Xml $settings -XPath "/settings/NewFarm" -Prompt "Do you wish to create a new farm? (Y/N)" if ($ConfigType -eq "N") { $DatabaseServer = Get-SettingValue -Xml $settings -XPath "/settings/DatabaseServer" -Prompt "Preparing to join existing farm. Please specify the name of your SQL Server"; $ConfigDB = Get-SettingValue -Xml $settings -XPath "/settings/ConfigDB" -Prompt "Next, specify the name of your Farm Configuration Database"; $Passphrase = Get-SettingValue -Xml $settings -XPath "/settings/Passphrase" -Prompt "Finally, please enter your Farm passphrase" -SecureString $true; } else { $DatabaseServer = Get-SettingValue -Xml $settings -XPath "/settings/DatabaseServer" -Prompt "Preparing to create a new Farm. Please specify the name of your SQL Server (ex SERVER or SERVER\INSTANCE[,PORT])"; $FarmName = Get-SettingValue -Xml $settings -XPath "/settings/FarmName" -Prompt "Please specify a name for your Farm (ex. SP2013Dev)"; $ConfigDB = $FarmName+"_ConfigDB"; $AdminContentDB = $FarmName+"_CentralAdminContent"; $FarmAcct = Get-CredentialValue -Xml $settings -UsernameXPath "/settings/FarmAccount/Username" -PasswordXpath "/settings/FarmAccount/Password" -Message "Please enter the credentials for your Farm Account (ex. COMPANYABC\SP_Farm)"; $Passphrase = Get-SettingValue -Xml $settings -XPath "/settings/Passphrase" -Prompt "Enter a secure Farm passphrase (must meet password complexity requirements)" -SecureString $true; $Port = Get-SettingValue -Xml $settings -XPath "/settings/CentralAdminPort" -Prompt "Enter a port number for the Central Administration Web App"; $Authentication = Get-SettingValue -Xml $settings -XPath "/settings/CentralAdminAuthentication" -Prompt "Finally, specify your authentication provider (NTLM/Kerberos)"; } $Passphrase = convertto-securestring $Passphrase -asplaintext -force if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { Add-PSSnapin Microsoft.SharePoint.PowerShell; } $ErrorActionPreference = "Stop" if ($ConfigType -eq "N") { Connect-SPConfigurationDatabase -DatabaseName $ConfigDB -DatabaseServer $DatabaseServer -Passphrase $Passphrase } else { Write-Host "Your SharePoint Farm is being configured..." New-SPConfigurationDatabase -DatabaseName $ConfigDB -DatabaseServer $DatabaseServer -AdministrationContentDatabaseName $AdminContentDB -Passphrase $Passphrase -FarmCredentials $FarmAcct } Initialize-SPResourceSecurity Install-SPService Install-SPFeature -AllExistingFeatures New-SPCentralAdministration -Port $Port -WindowsAuthProvider $Authentication Install-SPHelpCollection -All Install-SPApplicationContent Write-Host "Your SharePoint 2013 Farm has been created!" if ($ConfigType -eq "Y") { $WebAppCreation = Get-SettingValue -Xml $settings -XPath "/settings/WebApp" -Prompt "Would you like to provision a Web Application using the default Team Site Template? (Y/N)"; if ($WebAppCreation -eq "Y") { $HostHeaderQ = Get-SettingValue -Xml $settings -XPath "/settings/WebAppHostHeaderQ" -Prompt "Would you like to specify a host header? (Y/N)"; if ($HostHeaderQ -eq "Y") { $HostHeader = Get-SettingValue -Xml $settings -XPath "/settings/WebAppHostHeader" -Prompt "Please specify a host header for your Web Application (ex. intranet.contoso.com)"; $URL = "http://"+$HostHeader; } else { $URL = "http://"+$env:COMPUTERNAME; } Write-Host "Creating your Web Application..."; $ap = New-SPAuthenticationProvider New-SPWebApplication -Name "SharePoint 2013 Team Site" -Port 80 -Url $URL -ApplicationPool "Content_AppPool" -ApplicationPoolAccount (Get-SPManagedAccount $FarmAcct.UserName) -DatabaseServer $DatabaseServer -DatabaseName ($FarmName + "_TeamSite_ContentDB_01") -AuthenticationProvider $ap; New-SPSite $URL -OwnerAlias $FarmAcct.UserName -Language 1033 -Template "STS#0" -Name "Team Site"; Write-Host "Configuration completed."; } else { Write-Host "Configuration completed."; } } $serviceAppsConfig = Get-SettingValue -Xml $settings -XPath "/settings/Services/ServiceAppsConfig" -Prompt "Do you wish to configure Service Applications? (Y/N)" if($serviceAppsConfig -eq "Y") { PowerShell -File "Configure-ServiceApps.ps1" $FarmName } else { Write-Host "Press any key to continue..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") }
# # SharePoint 2013 Unleased - PowerShell farm config script # Copyright: Toni Frankola, Michael Noel # Version: 2.1, Feb 2013. # # Source: http://tinyurl.com/SP2013-Config # Licensed under the MIT License: # http://www.opensource.org/licenses/mit-license.php # cls Remove-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { Add-PSSnapin Microsoft.SharePoint.PowerShell; } $path = Get-Location $settings = Get-Content ($path.Path + "\settings.xml") -ErrorAction SilentlyContinue $ErrorActionPreference = "Stop" $spVer = (Get-PSSnapin microsoft.sharepoint.powershell).Version.Major Function Get-SettingValue { param($Xml, [string]$XPath, [string]$Prompt, [bool]$SecureString = $false) if($Xml -ne $null -and $Xml.SelectSingleNode($XPath) -ne $null -and $Xml.SelectSingleNode($XPath).InnerXml -ne "") { return $Xml.SelectSingleNode($XPath).InnerXml } else { if($SecureString) { $value = Read-Host $Prompt -AsSecureString; } else { $value = Read-Host $Prompt; } return $value; } } Function Get-CredentialValue { param($Xml, [string]$UsernameXPath, [string]$PasswordXPath, [string]$AccountName = "", [string]$Message) if($Xml -ne $null -and $Xml.SelectSingleNode($UsernameXPath) -ne $null -and $Xml.SelectSingleNode($UsernameXPath).InnerXml -ne "" -and $Xml.SelectSingleNode($PasswordXPath) -ne $null -and $Xml.SelectSingleNode($PasswordXPath).InnerXml -ne "") { $username = $Xml.SelectSingleNode($UsernameXPath).InnerXml; $password = $Xml.SelectSingleNode($PasswordXPath).InnerXml $password = convertto-securestring $password -asplaintext -force; return new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password } else { return Get-Credential $AccountName -Message $Message } } function Start-SPService($ServiceInstanceTypeName) { $ServiceInstance = (Get-SPServiceInstance | Where {$_.TypeName -eq $ServiceInstanceTypeName}) if($ServiceInstance -ne $null -and $ServiceInstance.Status -ne "Online" -and $ServiceInstance.Status -ne "Provisioning") { $ServiceInstance | Start-SPServiceInstance } $i = 0; while(-not ($ServiceInstance.Status -eq "Online") -and $i -lt 10) { Write-Host -ForegroundColor Yellow "Waiting for the $ServiceInstanceTypeName service to provision..."; sleep 100; $ServiceInstance = (Get-SPServiceInstance | Where {$_.TypeName -eq $ServiceInstanceTypeName}) $i += 1; if($i -eq 10) { Write-Host -ForegroundColor Yellow "It seems Service $ServiceInstanceTypeName has not yet been provisioned. We will continue with other stuff now." if($continue -eq "Y") { $i = 0; } } } } Function Configure-SPSearch { PARAM($AppPool, $FarmName, $SearchServiceAccount) $searchServiceInstance = Get-SPEnterpriseSearchServiceInstance -local Start-SPEnterpriseSearchServiceInstance -Identity $searchServiceInstance $dbName = $FarmName + "_SearchServiceApplication" $searchApplication = New-SPEnterpriseSearchServiceApplication -Name "$FarmName Search Service Application" -ApplicationPool $AppPool -DatabaseName $dbName $searchApplicationProxy = New-SPEnterpriseSearchServiceApplicationProxy -name "$FarmName Search Service Application Proxy" -SearchApplication $searchApplication Set-SPEnterpriseSearchAdministrationComponent -SearchApplication $searchApplication -SearchServiceInstance $searchServiceInstance $crawlTopology = New-SPEnterpriseSearchCrawlTopology -SearchApplication $searchApplication $crawlDatabase = Get-SPEnterpriseSearchCrawlDatabase -SearchApplication $searchApplication New-SPEnterpriseSearchCrawlComponent -CrawlTopology $crawlTopology -CrawlDatabase $crawlDatabase -SearchServiceInstance $searchServiceInstance while($crawlTopology.State -ne "Active") { $crawlTopology | Set-SPEnterpriseSearchCrawlTopology -Active -ErrorAction SilentlyContinue if ($crawlTopology.State -ne "Active") { Start-Sleep -Seconds 10 } } $queryTopology = New-SPenterpriseSEarchQueryTopology -SearchApplication $searchApplication -partitions 1 $searchIndexPartition = Get-SPEnterpriseSearchIndexPartition -QueryTopology $queryTopology New-SPEnterpriseSearchQueryComponent -indexpartition $searchIndexPartition -QueryTopology $queryTopology -SearchServiceInstance $searchServiceInstance $propertyDB = Get-SPEnterpriseSearchPropertyDatabase -SearchApplication $searchApplication Set-SPEnterpriseSearchIndexPartition $searchIndexPartition -PropertyDatabase $propertyDB while ($queryTopology.State -ne "Active") { $queryTopology | Set-SPEnterpriseSearchQueryTopology -Active -ErrorAction SilentlyContinue if ($queryTopology.State -ne "Active") { Start-Sleep -Seconds 10 } } } function Start-SPTimer { $spTimerService = Get-Service "SPTimerV4" if($spTimerService.Status -ne "Running") { Write-Host -ForegroundColor Yellow "SharePoint 2013 Timer Service is not running. Atempting to start the timer." Start-Service "SPTimerV4" $spTimerService = Get-Service "SPTimerV4" while($spTimerService.Status -ne "Running") { Start-Sleep -Seconds 10 Start-Service "SPTimerV4" $spTimerService = Get-Service "SPTimerV4" } Write-Host -ForegroundColor Green "SharePoint 2013 Timer Service is running." } else { Write-Host -ForegroundColor Green "SharePoint 2013 Timer Service is running." } } Function Get-SPServiceApplicationPoolByName($SPApplicationPoolName, $ManagedAccount) { $appPool = Get-SPServiceApplicationPool | Where {$_.Name -eq $SPApplicationPoolName} if($appPool -eq $null) { $appPool = New-SPServiceApplicationPool -Name $SPApplicationPoolName -Account $ManagedAccount } Return $appPool } Function Get-SPManagedAccountByName($AccountName, $Xml) { $managedAccount = Get-SPManagedAccount | Where {$_.Username -eq $AccountName} if($managedAccount -eq $null) { $managedAccountCredential = Get-CredentialValue -Xml $Xml -UsernameXPath "/settings/Services/ServiceAccount/Username" -PasswordXPath "/settings/Services/ServiceAccount/Password" $AccountName -Message "Please enter the credentials for your Managed Account ($AccountName)"; $managedAccount = New-SPManagedAccount $managedAccountCredential } Return $managedAccount } Function Get-SPServiceApplicationByType($TypeName) { $serviceApplications = Get-SPServiceApplication | Where {$_.TypeName -eq $TypeName} if($serviceApplications -ne $null) { $true; } else { $false; } } Function New-SPUsageApplicationAndProxy($FarmName) { Write-Host -ForegroundColor Yellow "Configuring Usage and Health Data Collection Service..." $dbName = $FarmName + "_UsageandHealthDataCollectionService" New-SPUsageApplication "$FarmName Usage and Health Data Collection Service" -DatabaseName $dbName $usageApplicationProxy = Get-SPServiceApplicationProxy | where{$_.Name -eq "$FarmName Usage and Health Data Collection Service"} if($usageApplicationProxy.Status -eq "Disabled") { $usageApplicationProxy.Status = "Online"; $usageApplicationProxy.Update(); } Write-Host -ForegroundColor Green "Installing Usage and Health Data Collection Service installed." } Function New-SPStateServiceApplicationGroup($FarmName){ $dbName = $FarmName + "_StateService" Write-Host -ForegroundColor Yellow "Installing State Service Application..." New-SPStateServiceDatabase $dbName | New-SPStateServiceApplication -Name "$FarmName State Service Application" | New-SPStateServiceApplicationProxy -Name "$FarmName State Service Application Proxy" -DefaultProxyGroup sleep 10; Write-Host -ForegroundColor Green "State Service Application installed..." } #arguments from Config-Farm script $FarmName=$args[0]; # Starting SP Timer Service Start-SPTimer if($appPoolName -eq $null -or $appPoolName -eq "") { $appPoolName = Get-SettingValue -Xml $settings -XPath "/settings/Services/ServiceAppPool" -Prompt "Please specify a name for the ServiceApp Application Pool (eg. ServiceAppPool)" } if($managedAccountName -eq $null -or $managedAccountName -eq "") { $managedAccountName = Get-SettingValue -Xml $settings -XPath "/settings/Services/ManagedAccountName" -Prompt "Please enter service account (eg. CompanyABC\sp_serviceapps)" } if($FarmName -eq $null -or $FarmName -eq "") { $FarmName = Get-SettingValue -Xml $settings -XPath "/settings/FarmName" -Prompt "Please enter your farm name"; } $managedAccount = Get-SPManagedAccountByName $managedAccountName $settings $appPool = Get-SPServiceApplicationPoolByName $appPoolName $managedAccount $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/StateServiceApplication" -Prompt "Would you like to install State Service Application? (Y/N)" if ($decision -eq "Y") { New-SPStateServiceApplicationGroup $FarmName } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/Access2010" -Prompt "Would you like to install Access Services 2010? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Access Service 2010 Service Installation" -Status "Starting Access Database Service 2010 Service" Start-SPService("Access Database Service 2010") Write-Progress -Activity "Access Service 2010 Service Installation" -Status "Creating Access Service 2010 Application" New-SPAccessServiceApplication -Name "$FarmName Access Services 2010" -ApplicationPool $appPool -Default Write-Progress -Activity "Access Service 2010 Service Installation" -Status "Completed" -Completed $true } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/BCS" -Prompt "Would you like to install Business Data Connectivity Service? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Business Data Connectivity Service Installation" -Status "Starting Business Data Connectivity Service" Start-SPService("Business Data Connectivity Service") $dbName = $FarmName + "_BusinessDataConnectivityService" Write-Progress -Activity "Business Data Connectivity Service Installation" -Status "Creating Business Data Connectivity Service Application" New-SPBusinessDataCatalogServiceApplication -Name "$FarmName Business Data Connectivity Service" -ApplicationPool $appPool -databaseName $dbName Write-Progress -Activity "Business Data Connectivity Service Installation" -Status "Completed" -Completed $true } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/UsageAndHealth" -Prompt "Would you like to configure Usage and Health Data Collection Service? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Usage and Health Data Collection Service Configuration" -Status "Configuring Usage and Health Data Collection Service" New-SPUsageApplicationAndProxy $FarmName Write-Progress -Activity "Usage and Health Data Collection Service Configuration" -Status "Completed" -Completed $true } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/Excel" -Prompt "Would you like to install Excel Services? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Excel Services Installation" -Status "Starting Excel Calculation Services" Start-SPService("Excel Calculation Services") Write-Progress -Activity "Excel Services Installation" -Status "Creating Excel Service Application" New-SPExcelServiceApplication -Name "$FarmName Excel Services" -ApplicationPool $appPool -Default Write-Host -ForegroundColor Green "Excel Services installed." Write-Progress -Activity "Excel Services Installation" -Status "Completed" -Completed $true } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/ManagedMetadata" -Prompt "Would you like to install Managed Metadata Service? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Managed Metadata Service Application Installation" -Status "Starting Managed Metadata Web Service" Start-SPService("Managed Metadata Web Service") $dbName = $FarmName + "_ManagedMetadataService" Write-Progress -Activity "Managed Metadata Service Application Installation" -Status "Creating Managed Metadata Service Application" $MetaDataServiceApp = New-SPMetadataServiceApplication -Name "$FarmName Managed Metadata Service" -ApplicationPool $appPool -DatabaseName $dbName $MetaDataServiceAppProxy = New-SPMetadataServiceApplicationProxy -Name "$FarmName Managed Metadata Service Proxy" -ServiceApplication $MetaDataServiceApp -DefaultProxyGroup Write-Progress -Activity "Managed Metadata Service Application Installation" -Status "Completed" -Completed $true } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/SecureStore" -Prompt "Would you like to install Secure Store Service? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Secure Store Service Application Installation" -Status "Starting Secure Store Service" Start-SPService("Secure Store Service") $dbName = $FarmName + "_SecureStore" Write-Progress -Activity "Secure Store Service Application Installation" -Status "Creating Secure Store Service Application" $secureStoreServiceApp = New-SPSecureStoreServiceApplication -Name "$FarmName Secure Store Service Application" -ApplicationPool $appPool -DatabaseName $dbName -AuditingEnabled:$true New-SPSecureStoreServiceApplicationProxy -ServiceApplication $secureStoreServiceApp -Name "$FarmName Secure Store Service Application Proxy" -DefaultProxyGroup Write-Progress -Activity "Secure Store Service Application Installation" -Status "Completed" -Completed $true } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/Visio" -Prompt "Would you like to install Visio Graphics Service? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Visio Graphics Service Application Installation" -Status "Starting Visio Graphics Service" Start-SPService("Visio Graphics Service") Write-Progress -Activity "Visio Graphics Service Application Installation" -Status "Creating Visio Graphics Service Application" New-SPVisioServiceApplication -Name "$FarmName Visio Graphics Service" -ApplicationPool $appPool Write-Progress -Activity "Visio Graphics Service Application Installation" -Status "Creating Visio Graphics Service Application Proxy" New-SPVisioServiceApplicationProxy -Name "$FarmName Visio Graphics Service Proxy" -ServiceApplication "$FarmName Visio Graphics Service" Write-Progress -Activity "Visio Graphics Service Application Installation" -Status "Completed" -Completed $true } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/Word" -Prompt "Would you like to install Word Automation Services? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Word Automation Services Application Installation" -Status "Starting Word Automation Services" Start-SPService("Word Automation Services") $dbName = $FarmName + "_WordAutomationService" Write-Progress -Activity "Word Automation Services Application Installation" -Status "Creating Word Automation Service Application" New-SPWordConversionServiceApplication -Name "$FarmName Word Automation Service" -ApplicationPool $appPool -DatabaseName $dbName -Default Write-Progress -Activity "Word Automation Services Application Installation" -Status "Completed" -Completed $true } if($spVer > 14) { $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/MachineTranslation" -Prompt "Would you like to install Machine Translation Service Application? (Y/N)" if ($decision -eq "Y") { $dbName = $FarmName + "_MachineTranslationService" Write-Progress -Activity "Machine Translation Service Application Installation" -Status "Starting Machine Translation Service" Start-SPService("Machine Translation Service") Write-Progress -Activity "Machine Translation Service Application Installation" -Status "Creating Machine Translation Service Application" New-SPTranslationServiceApplication -Name "$FarmName Machine Translation Service" -ApplicationPool $appPool -DatabaseName $dbName Write-Progress -Activity "Machine Translation Service Application Installation" -Status "Completed" -Completed $true } } $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/PerformancePoint" -Prompt "Would you like to install PerformancePoint Service Application? (Y/N)" if ($decision -eq "Y") { $dbName = $FarmName + "_PerformancePoint" Write-Progress -Activity "PerformancePoint Service Application Installation" -Status "Starting PerformancePoint Service" Start-SPService("PerformancePoint Service") Write-Progress -Activity "PerformancePoint Service Application Installation" -Status "Creating PerformancePoint Service Service Application" New-SPPerformancePointServiceApplication -Name "$FarmName PerformancePoint Service" -ApplicationPool $appPool -DatabaseName $dbName Write-Progress -Activity "PerformancePoint Service Application Installation" -Status "Completed" -Completed $true } if($spVer > 14) { $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/Search" -Prompt "Would you like to install Search Service? (Y/N)" if ($decision -eq "Y") { Write-Progress -Activity "Search Service Application Installation" -Status "Starting Search Service Application" $hostname = (Get-ChildItem env:computername).Value Start-SPEnterpriseSearchServiceInstance $hostname Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $hostname $dbName = $FarmName + "_SearchService" Write-Progress -Activity "Search Service Application Installation" -Status "Creating Search Service Application" $SearchServiceApp = New-SPEnterpriseSearchServiceApplication -Name "$FarmName Search Service Application" -ApplicationPool $appPool -DatabaseName $dbName $SearchServiceAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$FarmName Search Service Proxy" -SearchApplication $SearchServiceApp Write-Progress -Activity "Search Service Application Installation" -Status "Configuring Topology" $clone = $searchServiceApp.ActiveTopology.Clone() $searchServiceInstance = Get-SPEnterpriseSearchServiceInstance New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance $clone.Activate() Write-Progress -Activity "Search Service Application Installation" -Status "Completed" -Completed $true } } if($spVer > 14) { $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/WorkManagement" -Prompt "Would you like to install Work Management Service Application? (Y/N)" if ($decision -eq "Y") { $dbName = $FarmName + "_WorkManagement" Write-Progress -Activity "Work Management Service Application Installation" -Status "Starting Work Management Service" Start-SPService("Work Management Service") Write-Progress -Activity "Work Management Service Application Installation" -Status "Creating Work Management Service Service Application" New-SPWorkManagementServiceApplication –Name "$FarmName Work Management Service" –ApplicationPool $appPool Write-Progress -Activity "Work Management Service Application Installation" -Status "Completed" -Completed $true } } Write-Host -ForegroundColor Yellow "WARNING: Only use this script for simple UPA scenarios e.g. ‘Active Directory Import’ option. If more advanced/complex customization of UPA is required, it is recommended to manually configure the service using SharePoint Central Admin." $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/UPA/Provision" -Prompt "Would you like to install User Profile Service Application? (Y/N)" if ($decision -eq "Y") { Write-Host -ForegroundColor Yellow "WARNING: This part of the script needs to run under Farm account with elevated privileges. Farm admin must be local admin while UPA is provisioning." $decision = Get-SettingValue -Xml $settings -XPath "/settings/Services/UPA/Confirm" -Prompt "Please confirm: SharePoint Farm admin account is local admin and I want to proceed with UPA provisioning (Y/N)?" if ($decision -eq "Y") { Restart-Service SPTimerV4 Write-Progress -Activity "User Profile Service Application Installation" -Status "Starting User Profile Service" Start-SPService "User Profile Service" $username = ((Get-SPFarm).DefaultServiceAccount).Name; $farmAccount = Get-CredentialValue -Xml $settings -UsernameXPath "/settings/FarmAccount/Username" -PasswordXpath "/settings/FarmAccount/Password" -AccountName $username -Message "Please enter farm account credentials."; Start-Process $PSHOME\powershell.exe -Credential $farmAccount -ArgumentList "-Command Start-Process $PSHOME\powershell.exe -ArgumentList '$path\Provision-UPA.ps1',$farmName,$appPoolName -Verb Runas" -Wait $upa = Get-SPServiceApplication | Where TypeName -eq "User Profile Service Application" $ups = Get-SPServiceInstance | Where TypeName -eq "User Profile Synchronization Service" $hostname = (Get-ChildItem env:computername).Value $upa.SetSynchronizationMachine($hostname, $ups.ID, $username, $farmAccount.GetNetworkCredential().password) Write-Progress -Activity "User Profile Service Application Installation" -Status "Starting User Profile Synchronization Service" Start-SPService "User Profile Synchronization Service" Write-Host "Please remove your farm account from local admins." } } iisreset Write-Host -ForegroundColor Green "Installation completed."
$FarmName=$args[0]; $AppPoolName=$args[1]; $dbName = $FarmName + "_UPA_"; if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { Add-PSSnapin Microsoft.SharePoint.PowerShell; } $appPool = Get-SPServiceApplicationPool $AppPoolName; Write-Progress -Activity "User Profile Service Application Installation" -Status "Creating User Profile Service" $upa = New-SPProfileServiceApplication –Name "$FarmName User Profile Service Application" -ApplicationPool $AppPoolName -ProfileDBName ($dbName + "ProfileDB") -SocialDBName ($dbName + "SocialDB") -ProfileSyncDBName ($dbName + "SyncDB") New-SPProfileServiceApplicationProxy -Name "$FarmName User Profile Service Proxy" –DefaultProxyGroup -ServiceApplication $upa