diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 index 389161207..348a4eb28 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 @@ -93,51 +93,44 @@ function Set-TargetResource if ($Ensure -eq "Present") { Write-Verbose "Adding the distributed cache to the server" - Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { - $params = $args[0] - Add-SPDistributedCacheServiceInstance - Update-SPDistributedCacheSize -CacheSizeInMB $params.CacheSizeInMB - } - - Write-Verbose "Update the identity used by AppFabric" - Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { + $InstallSuccess = Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { $params = $args[0] - - $farm = Get-SPFarm - $cacheService = $farm.Services | where {$_.Name -eq "AppFabricCachingService"} - $cacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser" - $cacheService.ProcessIdentity.ManagedAccount = Get-SPManagedAccount -Identity $params.ServiceAccount - $cacheService.ProcessIdentity.Update() - $cacheService.ProcessIdentity.Deploy() + try + { + Add-xSharePointDistributedCacheServer -CacheSizeInMB $params.CacheSizeInMB -ServiceAccount $params.ServiceAccount + } + catch + { + try { Remove-xSharePointDistributedCacheServer } catch {} + return $false + } + return $true } - if($createFirewallRules) { - Write-Verbose "Update the identity used by AppFabric" - Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { - $params = $args[0] - Import-Module NetSecurity - - $firewallRule = Get-NetFirewallRule -DisplayName "SharePoint Distribute Cache" -ErrorAction SilentlyContinue - if($firewallRule -eq $null) { - New-NetFirewallRule -Name "SPDistCache" -DisplayName "SharePoint Distribute Cache" -Protocol TCP -LocalPort 22233-22236 + if($InstallSuccess -eq $false) { + #Write-Verbose "Encountered error proivisioning Distribute Cache. Rebooting server to reattempt" + #$global:DSCMachineStatus = 1 + } else { + if($createFirewallRules) { + Write-Verbose "Create a firewall rule for AppFabric" + Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { + $params = $args[0] + Import-Module NetSecurity + + $firewallRule = Get-NetFirewallRule -DisplayName "SharePoint Distribute Cache" -ErrorAction SilentlyContinue + if($firewallRule -eq $null) { + New-NetFirewallRule -Name "SPDistCache" -DisplayName "SharePoint Distribute Cache" -Protocol TCP -LocalPort 22233-22236 + } + Enable-NetFirewallRule -DisplayName "SharePoint Distribute Cache" } - Enable-NetFirewallRule -DisplayName "SharePoint Distribute Cache" + Write-Verbose "Firewall rule added" } - Write-Verbose "Firewall rule added" } } else { Write-Verbose "Removing distributed cache to the server" Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { $params = $args[0] - - $farm = Get-SPFarm - $cacheClusterName = "SPDistributedCacheCluster_" + $farm.Id.ToString() - $cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local - $cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName); - $instanceName ="SPDistributedCacheService Name=AppFabricCachingService" - $serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq $env:computername} - $serviceInstance.Delete() - Remove-SPDistributedCacheServiceInstance + Remove-xSharePointDistributedCacheServer } $firewallRule = Get-NetFirewallRule -DisplayName "SharePoint Distribute Cache" -ErrorAction SilentlyContinue diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 index 2886464cb..735494741 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 @@ -133,6 +133,12 @@ function Set-TargetResource Write-Verbose "Starting timer service" Start-Service sptimerv4 + + Write-Verbose "Pausing for 5 minutes to allow the timer service to fully provision the server" + Start-Sleep -Seconds 300 + Write-Verbose "Join farm complete. Restarting computer to allow configuration to continue" + + $global:DSCMachineStatus = 1 } diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.psm1 index abe83d9b1..e2739b9b9 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPManagedMetadataServiceApp/MSFT_xSPManagedMetaDataServiceApp.psm1 @@ -64,7 +64,7 @@ function Set-TargetResource $InstallAccount ) - $result = Get-TargetResource -Name $Name -ApplicationPool $ApplicationPool -InstallAccount $InstallAccount + $result = Get-TargetResource -Name $Name -InstallAccount $InstallAccount $session = Get-xSharePointAuthenticatedPSSession $InstallAccount if ($result.Count -eq 0) { Write-Verbose "Creating Managed Metadata Service Application $Name" diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.psm1 index bffef537e..37e948816 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.psm1 @@ -76,7 +76,7 @@ function Set-TargetResource Get-SPEnterpriseSearchServiceInstance -Local | Start-SPEnterpriseSearchServiceInstance -ErrorAction SilentlyContinue $app = New-SPEnterpriseSearchServiceApplication @params if ($app) { - New-SPEnterpriseSearchServiceApplicationProxy -Name "$Name Proxy" -SearchApplication $app + New-SPEnterpriseSearchServiceApplicationProxy -Name ($params.Name + " Proxy") -SearchApplication $app } } } diff --git a/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 b/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 new file mode 100644 index 000000000..ea347bb54 --- /dev/null +++ b/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 @@ -0,0 +1,35 @@ +function Add-xSharePointDistributedCacheServer() { + [CmdletBinding()] + param + ( + [parameter(Mandatory = $true,Position=1)] + [System.Uint32] + $CacheSizeInMB, + + [parameter(Mandatory = $true,Position=2)] + [System.String] + $ServiceAccount + ) + + Add-SPDistributedCacheServiceInstance + Update-SPDistributedCacheSize -CacheSizeInMB $CacheSizeInMB + $farm = Get-SPFarm + $cacheService = $farm.Services | where {$_.Name -eq "AppFabricCachingService"} + $cacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser" + $cacheService.ProcessIdentity.ManagedAccount = (Get-SPManagedAccount -Identity $ServiceAccount) + $cacheService.ProcessIdentity.Update() + $cacheService.ProcessIdentity.Deploy() +} + +function Remove-xSharePointDistributedCacheServer() { + $farm = Get-SPFarm + $cacheClusterName = "SPDistributedCacheCluster_" + $farm.Id.ToString() + $cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local + $cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName); + $instanceName ="SPDistributedCacheService Name=AppFabricCachingService" + $serviceInstance = Get-SPServiceInstance | ? {($_.Service.Tostring()) -eq $instanceName -and ($_.Server.Name) -eq $env:computername} + $serviceInstance.Delete() + Remove-SPDistributedCacheServiceInstance +} + +Export-ModuleMember -Function * diff --git a/Modules/xSharePoint/xSharePoint.psd1 b/Modules/xSharePoint/xSharePoint.psd1 index b034af8fb..635622ed1 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -17,14 +17,14 @@ ModuleVersion = '0.2.0' # ID used to uniquely identify this module GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90' -# Author of this module -Author = ''Microsoft Corporation' +# Author of this module +Author = 'Microsoft Corporation' # Company or vendor of this module -CompanyName = ''Microsoft Corporation' +CompanyName = 'Microsoft Corporation' # Copyright statement for this module -Copyright = '(c) 2015 'Microsoft Corporation. All rights reserved.' +Copyright = '(c) 2015 Microsoft Corporation. All rights reserved.' # Description of the functionality provided by this module Description = 'This DSC module is used to deploy and configure SharePoint Server 2013, and convers a wide range of areas including web apps, service apps and farm configuration.' @@ -63,7 +63,8 @@ Description = 'This DSC module is used to deploy and configure SharePoint Server # FormatsToProcess = @() # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -NestedModules = @("modules\xSharePoint.Util\xSharePoint.Util.psm1") +NestedModules = @("modules\xSharePoint.DistributedCache\xSharePoint.DistributedCache.psm1", + "modules\xSharePoint.Util\xSharePoint.Util.psm1") # Functions to export from this module FunctionsToExport = '*' diff --git a/README.md b/README.md index ca46bc2ab..561453907 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Please leave comments, feature requests, and bug reports in the Q & A tab for th If you would like to modify xSharePoint module, please feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform. -Pleaes refer to the [Contribution Guidelines](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md) for information about style guides, testing and patterns for contributing to DSC resources. +Pleaes refer to the [Contribution Guidelines](https://github.com/PowerShell/xSharePoint/wiki/Contributing%20to%20xSharePoint) for information about style guides, testing and patterns for contributing to DSC resources. ## Installation