Examples/Small Farm/SharePoint.ps1
Configuration Example { param ( [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $FarmAccount, [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $SPSetupAccount, [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $WebPoolManagedAccount, [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $ServicePoolManagedAccount, [Parameter(Mandatory=$true)] [ValidateNotNullorEmpty()] [PSCredential] $Passphrase ) Import-DscResource -ModuleName PSDesiredStateConfiguration Import-DscResource -ModuleName SharePointDsc node "Server1" { #********************************************************** # Install Binaries # # This section installs SharePoint and its Prerequisites #********************************************************** SPInstallPrereqs InstallPrereqs { Ensure = "Present" InstallerPath = "C:\binaries\prerequisiteinstaller.exe" OnlineMode = $true } SPInstall InstallSharePoint { Ensure = "Present" BinaryDir = "C:\binaries\" ProductKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" DependsOn = "[SPInstallPrereqs]InstallPrereqs" } #********************************************************** # Basic farm configuration # # This section creates the new SharePoint farm object, and # provisions generic services and components used by the # whole farm #********************************************************** SPCreateFarm CreateSPFarm { DatabaseServer = "sql.contoso.com" FarmConfigDatabaseName = "SP_Config" Passphrase = $Passphrase FarmAccount = $FarmAccount PsDscRunAsCredential = $SPSetupAccount AdminContentDatabaseName = "SP_AdminContent" DependsOn = "[SPInstall]InstallSharePoint" } SPManagedAccount ServicePoolManagedAccount { AccountName = $ServicePoolManagedAccount.UserName Account = $ServicePoolManagedAccount PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } SPManagedAccount WebPoolManagedAccount { AccountName = $WebPoolManagedAccount.UserName Account = $WebPoolManagedAccount PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } SPDiagnosticLoggingSettings ApplyDiagnosticLogSettings { PsDscRunAsCredential = $SPSetupAccount LogPath = "C:\ULS" LogSpaceInGB = 5 AppAnalyticsAutomaticUploadEnabled = $false CustomerExperienceImprovementProgramEnabled = $true DaysToKeepLogs = 7 DownloadErrorReportingUpdatesEnabled = $false ErrorReportingAutomaticUploadEnabled = $false ErrorReportingEnabled = $false EventLogFloodProtectionEnabled = $true EventLogFloodProtectionNotifyInterval = 5 EventLogFloodProtectionQuietPeriod = 2 EventLogFloodProtectionThreshold = 5 EventLogFloodProtectionTriggerPeriod = 2 LogCutInterval = 15 LogMaxDiskSpaceUsageEnabled = $true ScriptErrorReportingDelay = 30 ScriptErrorReportingEnabled = $true ScriptErrorReportingRequireAuth = $true DependsOn = "[SPCreateFarm]CreateSPFarm" } SPUsageApplication UsageApplication { Name = "Usage Service Application" DatabaseName = "SP_Usage" UsageLogCutTime = 5 UsageLogLocation = "C:\UsageLogs" UsageLogMaxFileSizeKB = 1024 PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } SPStateServiceApp StateServiceApp { Name = "State Service Application" DatabaseName = "SP_State" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } SPDistributedCacheService EnableDistributedCache { Name = "AppFabricCachingService" Ensure = "Present" CacheSizeInMB = 1024 ServiceAccount = $ServicePoolManagedAccount.UserName PsDscRunAsCredential = $SPSetupAccount CreateFirewallRules = $true DependsOn = @('[SPCreateFarm]CreateSPFarm','[SPManagedAccount]ServicePoolManagedAccount') } #********************************************************** # Web applications # # This section creates the web applications in the # SharePoint farm, as well as managed paths and other web # application settings #********************************************************** SPWebApplication SharePointSites { Name = "SharePoint Sites" ApplicationPool = "SharePoint Sites" ApplicationPoolAccount = $WebPoolManagedAccount.UserName AllowAnonymous = $false AuthenticationMethod = "NTLM" DatabaseName = "SP_Content" Url = "http://sites.contoso.com" HostHeader = "sites.contoso.com" Port = 80 PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPManagedAccount]WebPoolManagedAccount" } SPCacheAccounts WebAppCacheAccounts { WebAppUrl = "http://sites.contoso.com" SuperUserAlias = "CONTOSO\SP_SuperUser" SuperReaderAlias = "CONTOSO\SP_SuperReader" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPWebApplication]SharePointSites" } SPSite TeamSite { Url = "http://sites.contoso.com" OwnerAlias = "CONTOSO\SP_Admin" Name = "DSC Demo Site" Template = "STS#0" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPWebApplication]SharePointSites" } #********************************************************** # Service instances # # This section describes which services should be running # and not running on the server #********************************************************** SPServiceInstance ClaimsToWindowsTokenServiceInstance { Name = "Claims to Windows Token Service" Ensure = "Present" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } SPServiceInstance SecureStoreServiceInstance { Name = "Secure Store Service" Ensure = "Present" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } SPServiceInstance SearchServiceInstance { Name = "SharePoint Server Search" Ensure = "Present" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } #********************************************************** # Service applications # # This section creates service applications and required # dependencies #********************************************************** $serviceAppPoolName = "SharePoint Service Applications" SPServiceAppPool MainServiceAppPool { Name = $serviceAppPoolName ServiceAccount = $ServicePoolManagedAccount.UserName PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPCreateFarm]CreateSPFarm" } SPSecureStoreServiceApp SecureStoreServiceApp { Name = "Secure Store Service Application" ApplicationPool = $serviceAppPoolName AuditingEnabled = $true AuditlogMaxSize = 30 DatabaseName = "SP_SecureStore" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPServiceAppPool]MainServiceAppPool" } SPManagedMetaDataServiceApp ManagedMetadataServiceApp { Name = "Managed Metadata Service Application" PsDscRunAsCredential = $SPSetupAccount ApplicationPool = $serviceAppPoolName DatabaseName = "SP_MMS" DependsOn = "[SPServiceAppPool]MainServiceAppPool" } SPBCSServiceApp BCSServiceApp { Name = "BCS Service Application" ApplicationPool = $serviceAppPoolName DatabaseName = "SP_BCS" PsDscRunAsCredential = $SPSetupAccount DependsOn = @('[SPServiceAppPool]MainServiceAppPool', '[SPSecureStoreServiceApp]SecureStoreServiceApp') } SPSearchServiceApp SearchServiceApp { Name = "Search Service Application" DatabaseName = "SP_Search" ApplicationPool = $serviceAppPoolName PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPServiceAppPool]MainServiceAppPool" } #********************************************************** # Local configuration manager settings # # This section contains settings for the LCM of the host # that this configuraiton is applied to #********************************************************** LocalConfigurationManager { RebootNodeIfNeeded = $true } } node "Server2" { #********************************************************** # Install Binaries # # This section installs SharePoint and its Prerequisites #********************************************************** SPInstallPrereqs InstallPrereqs { Ensure = "Present" InstallerPath = "C:\binaries\prerequisiteinstaller.exe" OnlineMode = $true } SPInstall InstallSharePoint { Ensure = "Present" BinaryDir = "C:\binaries\" ProductKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" DependsOn = "[SPInstallPrereqs]InstallPrereqs" } #********************************************************** # Basic farm configuration # # This section creates the new SharePoint farm object, and # provisions generic services and components used by the # whole farm #********************************************************** SPJoinFarm JoinSPFarm { DatabaseServer = "sql.contoso.com" FarmConfigDatabaseName = "SP_Config" Passphrase = $Passphrase PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPInstall]InstallSharePoint" } SPDistributedCacheService EnableDistributedCache { Name = "AppFabricCachingService" Ensure = "Present" CacheSizeInMB = 1024 ServiceAccount = $ServicePoolManagedAccount.UserName PsDscRunAsCredential = $SPSetupAccount CreateFirewallRules = $true DependsOn = "[SPJoinFarm]JoinSPFarm" } #********************************************************** # Service instances # # This section describes which services should be running # and not running on the server #********************************************************** SPServiceInstance ClaimsToWindowsTokenServiceInstance { Name = "Claims to Windows Token Service" Ensure = "Present" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPJoinFarm]JoinSPFarm" } SPServiceInstance ManagedMetadataServiceInstance { Name = "Managed Metadata Web Service" Ensure = "Present" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPJoinFarm]JoinSPFarm" } SPServiceInstance BCSServiceInstance { Name = "Business Data Connectivity Service" Ensure = "Present" PsDscRunAsCredential = $SPSetupAccount DependsOn = "[SPJoinFarm]JoinSPFarm" } #********************************************************** # Local configuration manager settings # # This section contains settings for the LCM of the host # that this configuraiton is applied to #********************************************************** LocalConfigurationManager { RebootNodeIfNeeded = $true } } } |