Skip to content

Commit

Permalink
Merging changes from the bug fix branch
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianFarnhill committed Apr 28, 2015
2 parents c2277e2 + 87a8bf3 commit 9c835b7
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 *
11 changes: 6 additions & 5 deletions Modules/xSharePoint/xSharePoint.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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 = '*'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9c835b7

Please sign in to comment.