From d7d968ea50537cc9b33fdcd57d514653c16f22ce Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 26 Apr 2015 16:07:32 +1000 Subject: [PATCH 1/5] Resolved bug in MMS set function Fixed a bug causing an error to stop the set method from updating the MMS successfully - this didn't cause a problem with initial provisioning, only updating --- .../MSFT_xSPManagedMetaDataServiceApp.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 74ba73e7a7bd2679fac8e51f6fc6473fa1a9bf24 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Sun, 26 Apr 2015 20:03:32 +1000 Subject: [PATCH 2/5] Bug fixes to DCache and search services --- .../MSFT_xSPDistributedCacheService.psm1 | 2 +- .../MSFT_xSPSearchServiceApp/MSFT_xSPSearchServiceApp.psm1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 index 389161207..0f2ae9152 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 @@ -112,7 +112,7 @@ function Set-TargetResource } if($createFirewallRules) { - Write-Verbose "Update the identity used by AppFabric" + Write-Verbose "Create a firewall rule for AppFabric" Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { $params = $args[0] Import-Module NetSecurity 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 } } } From d1f74adb1bd1d89bf4e2e6b2f78168bbb8e81251 Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Tue, 28 Apr 2015 14:09:11 +1000 Subject: [PATCH 3/5] Fixes for distributed cache --- .../MSFT_xSPDistributedCacheService.psm1 | 69 +++++++++---------- .../MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 | 6 ++ .../xSharePoint.DistributedCache.psm1 | 35 ++++++++++ Modules/xSharePoint/xSharePoint.psd1 | 9 +-- README.md | 2 +- 5 files changed, 78 insertions(+), 43 deletions(-) create mode 100644 Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 index 0f2ae9152..1e0442730 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 "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" - } - Write-Verbose "Firewall rule added" - } + 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" + } + 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..05135ba18 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/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 b/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 new file mode 100644 index 000000000..e35b49236 --- /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 6e86b52ec..4b927b864 100644 --- a/Modules/xSharePoint/xSharePoint.psd1 +++ b/Modules/xSharePoint/xSharePoint.psd1 @@ -18,13 +18,13 @@ ModuleVersion = '0.2.0' GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90' # Author of this module -Author = 'Brian Farnhill, Andrew Lynes, Cam Adams, Arian Nevjestic, Janhavi Antukar, Tarang Soni' +Author = 'Microsoft Corporation' # Company or vendor of this module -CompanyName = 'Microsoft' +CompanyName = 'Microsoft Corporation' # Copyright statement for this module -Copyright = '(c) 2015 Microsoft. 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 From c428b3b94de60798119fbdfa37f6f9e0ec71831f Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Tue, 28 Apr 2015 14:15:30 +1000 Subject: [PATCH 4/5] Fixed tabs/spaces for formatting --- .../MSFT_xSPDistributedCacheService.psm1 | 56 +++++++++---------- .../xSharePoint.DistributedCache.psm1 | 4 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 index 1e0442730..348a4eb28 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.psm1 @@ -95,37 +95,37 @@ function Set-TargetResource Write-Verbose "Adding the distributed cache to the server" $InstallSuccess = Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { $params = $args[0] - try - { - Add-xSharePointDistributedCacheServer -CacheSizeInMB $params.CacheSizeInMB -ServiceAccount $params.ServiceAccount - } + try + { + Add-xSharePointDistributedCacheServer -CacheSizeInMB $params.CacheSizeInMB -ServiceAccount $params.ServiceAccount + } catch - { - try { Remove-xSharePointDistributedCacheServer } catch {} - return $false - } - return $true + { + try { Remove-xSharePointDistributedCacheServer } catch {} + return $false + } + return $true } - 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" - } - Write-Verbose "Firewall rule added" - } - } + 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" + } + Write-Verbose "Firewall rule added" + } + } } else { Write-Verbose "Removing distributed cache to the server" Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock { diff --git a/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 b/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 index e35b49236..ea347bb54 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.DistributedCache/xSharePoint.DistributedCache.psm1 @@ -13,7 +13,7 @@ function Add-xSharePointDistributedCacheServer() { Add-SPDistributedCacheServiceInstance Update-SPDistributedCacheSize -CacheSizeInMB $CacheSizeInMB - $farm = Get-SPFarm + $farm = Get-SPFarm $cacheService = $farm.Services | where {$_.Name -eq "AppFabricCachingService"} $cacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser" $cacheService.ProcessIdentity.ManagedAccount = (Get-SPManagedAccount -Identity $ServiceAccount) @@ -22,7 +22,7 @@ function Add-xSharePointDistributedCacheServer() { } function Remove-xSharePointDistributedCacheServer() { - $farm = Get-SPFarm + $farm = Get-SPFarm $cacheClusterName = "SPDistributedCacheCluster_" + $farm.Id.ToString() $cacheClusterManager = [Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager]::Local $cacheClusterInfo = $cacheClusterManager.GetSPDistributedCacheClusterInfo($cacheClusterName); From 87a8bf31fa42da29730a1271086dd647df21ed4d Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Tue, 28 Apr 2015 14:17:49 +1000 Subject: [PATCH 5/5] Fixed tabs/spaces for formatting --- .../DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 index 05135ba18..735494741 100644 --- a/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 +++ b/Modules/xSharePoint/DSCResources/MSFT_xSPJoinFarm/MSFT_xSPJoinFarm.psm1 @@ -134,11 +134,11 @@ 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" + 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 + $global:DSCMachineStatus = 1 }