Showing posts with label 20339. Show all posts
Showing posts with label 20339. Show all posts

Friday, December 22, 2017

SharePoint PowerShell 20339 Reference Guide

PowerShell SharePoint Code Examples

Here are examples inspired from the SharePoint Farm course 20339-1/20339-2

20339-1

Module 5: Installing and configuring SharePoint 2016

OOS Basic Setup

On OOS server …

New-OfficeWebAppsFarm -InternalURL “http://$env:COMPUTERNAME” –AllowHttp:$true –EditingEnabled:$true

On SharePoint server …

New-SPWOPIBinding -ServerName NYC-OOS –AllowHTTP:$true
Set-SPWOPIZone -Zone "internal-http"
$config = Get-SPSecurityTokenServiceConfig
$config.AllowOAuthOverHttp = $true
$config.Update()

Module 6 – Web Applications and Site Collections

Site Collection

New-SPContentDatabase -Name WSS_Content_TeamArchive -WebApplication http://teams.contoso.com

New-SPSite -Url "http://teams.contoso.com/team/archive" -ContentDatabase WSS_Content_TeamArchive -Name "Team Archive" -OwnerAlias CONTOSO\Administrator -Template "STS#0"


Module 7 – Service Applications

Managed Metadata

New-ADUser -SamAccountName SPSalesMMS -Name "SharePoint Sales MMS" -UserPrincipalName "SPSalesMMS@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoSalesMMSAppPool -Account SPSalesMMS@contoso.com

$MMS = New-SPMetadataServiceApplication -Name "Contoso Sales Managed Metadata" -ApplicationPool $AppPool -DatabaseName ContosoSalesMMS -HubUri http://sales.contoso.com

New-SPMetadataServiceApplicationProxy -Name "Contoso Sales Managed Metadata" -ServiceApplication $MMS -DefaultProxyGroup

Word Automation

New-ADUser -SamAccountName SPWordAutomation -Name "SP Word Automation" -UserPrincipalName "SPWordAutomation@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoWordAutomationAppPool -Account SPWordAutomation@contoso.com

$WCS = New-SPWordConversionServiceApplication -Name "Contoso Word Automation Service" -ApplicationPool $AppPool -DatabaseName ContosoWordAutomation

20339-2

Module 1

Farm configuration

New-SPConfigurationDatabase –DatabaseServer “ContosoDB” –DatabaseName “SharePoint_Config” –AdministrationContentDatabaseName “SharePoint Farm Content” –Passphrase (Read-Host –Prompt “Enter Farm PassPhrase” –AsSecureString) –FarmCredentials (Get-Credential –Message “Enter Farm Account Credential”) –LocalServerRole “Custom”

To create the ACL resources

Initialize-SPResourceSecurity

Install the required services

Install-SPService

Install the SharePoint features

Install-SPFeature -AllExistingFeatures

Create Central Administration

New-SPCentralAdministration -Port 50000 -WindowsAuthProvider NTLM

Install the Help Collection

Install-SPHelpCollection -All

Complete the installation of Central Administration

Install-SPApplicationContent

Create Default App Pool – Note that spservices account must be setup in AD

$appPoolCred = Get-Credential –Credential “contoso\spServices”

$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred

$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”

Search

$saAppPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

Start-SPEnterpriseSearchServiceInstance $env:COMPUTERNAME

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $env:COMPUTERNAME

$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name “Search Service Application” -ApplicationPool $saAppPool -DatabaseServer “ContosoDB” -DatabaseName “Farm_SSA”

$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name “Search Service Application Proxy” -SearchApplication $searchServiceApp

[IO.Directory]::CreateDirectory(“c:\spSearchIndex”)

$clone = $searchServiceApp.ActiveTopology.Clone()

$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local

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 -RootDirectory “c:\spSearchIndex”;

New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

$clone.Activate()


User Profile Service

$saAppPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$upa = New-SPProfileServiceApplication –Name “User Profile Service” -ApplicationPool $saAppPool -ProfileDBName “Farm_UPA_Profile” -ProfileSyncDBServer “ContosoDB” -SocialDBName “Farm_UPA_Social” -SocialDBServer “ContosoDB” -ProfileSyncDBName “Farm_UPA_Sync” -ProfileDBServer “ContosoDB”

New-SPProfileServiceApplicationProxy -Name " User Profile Service Proxy" -ServiceApplication $upa –DefaultProxyGroup

Get-SPServiceInstance | where-object {$_.TypeName -eq “User Profile Service”} | Start-SPServiceInstance

Module 2

Office 365 Prerequisites

Create Default App Pool – Note that spservices account must be setup in AD

$appPoolCred = Get-Credential –Credential “contoso\spServices”

$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred

$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”

App Management

$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$amsa = New-SPAppManagementServiceApplication -Name “App Management Service” -DatabaseName “Farm_App_Management” –ApplicationPool $appPool

$amsaProxy = New-SPAppManagementServiceApplicationProxy -Name " App Management Service Proxy" -UseDefaultProxyGroup -ServiceApplication $amsa

Get-SPServiceInstance | Where-Object {$_.TypeName -like "*App Management Service*"} | Start-SPServiceInstance

Subscription Service

$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$SSSA = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -Name "Subscription Settings Service"

$sssaProxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $SSSA

$spInstances = Get-SPServiceInstance; $spInstances.Where{$_.TypeName -like "*Subscription Settings Service*"} | Start-SPServiceInstance


Appendix

State Service

$serviceApp = New-SPStateServiceApplication -Name "StateService-App"

New-SPStateServiceDatabase -Name "SS-Database" -ServiceApplication $serviceApp

New-SPStateServiceApplicationProxy -Name "StateService-App" -ServiceApplication $serviceApp -DefaultProxyGroup