-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from PowerShell/release-v0.12
Release v0.12
- Loading branch information
Showing
140 changed files
with
4,172 additions
and
1,562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
*.suo | ||
*.user | ||
*.coverage | ||
.vs | ||
.vs | ||
.psproj | ||
.sln |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "PowerShell", | ||
"type": "PowerShell", | ||
"request": "launch", | ||
"program": "RunPesterTests.ps1" | ||
} | ||
] | ||
} |
101 changes: 101 additions & 0 deletions
101
Modules/xSharePoint/DSCResources/MSFT_xSPAlternateUrl/MSFT_xSPAlternateUrl.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $WebAppUrl, | ||
[parameter(Mandatory = $true)] [ValidateSet("Default","Intranet","Extranet","Custom","Internet")] [System.String] $Zone, | ||
[parameter(Mandatory = $false)] [System.String] $Url, | ||
[parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
|
||
) | ||
|
||
Write-Verbose -Message "Getting Alternate URL for $Zone in $WebAppUrl" | ||
|
||
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
$aam = Get-SPAlternateURL -WebApplication $params.WebAppUrl -Zone $params.Zone | Select -First 1 | ||
$url = $null | ||
$Ensure = "Absent" | ||
if ($aam -ne $null) { | ||
$url = $aam.PublicUrl | ||
$Ensure = "Present" | ||
} | ||
|
||
return @{ | ||
WebAppUrl = $params.WebAppUrl | ||
Zone = $params.Zone | ||
Url = $url | ||
Ensure = $Ensure | ||
InstallAccount = $params.InstallAccount | ||
} | ||
} | ||
return $result | ||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $WebAppUrl, | ||
[parameter(Mandatory = $true)] [ValidateSet("Default","Intranet","Extranet","Custom","Internet")] [System.String] $Zone, | ||
[parameter(Mandatory = $false)] [System.String] $Url, | ||
[parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
|
||
) | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
|
||
Write-Verbose -Message "Updating app domain settings for $SiteUrl" | ||
|
||
if ($Ensure -eq "Present") { | ||
if ([string]::IsNullOrEmpty($Url)) { | ||
throw "URL must be specified when ensure is set to present" | ||
} | ||
|
||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $CurrentValues) -ScriptBlock { | ||
$params = $args[0] | ||
$CurrentValues = $args[1] | ||
|
||
if ([string]::IsNullOrEmpty($CurrentValues.Url)) { | ||
New-SPAlternateURL -WebApplication $params.WebAppUrl -Url $params.Url -Zone $params.Zone | ||
} else { | ||
Get-SPAlternateURL -WebApplication $params.WebAppUrl -Zone $params.Zone | Set-SPAlternateURL -Url $params.Url | ||
} | ||
} | ||
} else { | ||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
Get-SPAlternateURL -WebApplication $params.WebAppUrl -Zone $params.Zone | Remove-SPAlternateURL -Confirm:$false | ||
} | ||
} | ||
} | ||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $WebAppUrl, | ||
[parameter(Mandatory = $true)] [ValidateSet("Default","Intranet","Extranet","Custom","Internet")] [System.String] $Zone, | ||
[parameter(Mandatory = $false)] [System.String] $Url, | ||
[parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
|
||
) | ||
|
||
if ([string]::IsNullOrEmpty($Url) -and $Ensure -eq "Present") { | ||
throw "URL must be specified when ensure is set to present" | ||
} | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
Write-Verbose -Message "Testing alternate URL configuration" | ||
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Url", "Ensure") | ||
} | ||
|
27 changes: 27 additions & 0 deletions
27
Modules/xSharePoint/DSCResources/MSFT_xSPAlternateUrl/MSFT_xSPAlternateUrl.schema.mof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
**Description** | ||
|
||
This resource is used to define an alternate access mapping URL for a specified web application. | ||
|
||
|
||
**Example** | ||
|
||
xSPAlternateUrl CentralAdminAAM | ||
{ | ||
WebAppUrl = "http://sharepoint1:9999" | ||
Zone = "Intranet" | ||
Url = "https://admin.sharepoint.contoso.com" | ||
PsDscRunAsCredential = $SPSetupAccount | ||
} | ||
*/ | ||
|
||
[ClassVersion("1.0.0.0"), FriendlyName("xSPAlternateUrl")] | ||
class MSFT_xSPAlternateUrl : OMI_BaseResource | ||
{ | ||
[Key, Description("The URL of the web application to apply the alternate URL to")] String WebAppUrl; | ||
[Key, Description("The Zone to use for the alternate URL"), ValueMap{"Default","Intranet","Extranet","Custom","Internet"}, Values{"Default","Intranet","Extranet","Custom","Internet"}] String Zone; | ||
[Write, Description("The new alternate URL")] String Url; | ||
[Required, Description("Present ensures the URL is set for this zone on this web app, Absent ensures it is removed"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; | ||
[Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsAccount if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
Modules/xSharePoint/DSCResources/MSFT_xSPDatabaseAAG/MSFT_xSPDatabaseAAG.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $DatabaseName, | ||
[parameter(Mandatory = $true)] [System.String] $AGName, | ||
[parameter(Mandatory = $false)] [System.String] $FileShare, | ||
[parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Getting current AAG config for $DatabaseName" | ||
|
||
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
$database = Get-SPDatabase | Where-Object { $_.Name -eq $params.DatabaseName } | ||
|
||
$Ensure = "Absent" | ||
$AGName = $params.AGName | ||
if ($database -ne $null) { | ||
$ag = $database.AvailabilityGroup | ||
if ($ag -ne $null) { | ||
$AGName = $ag.Name | ||
if ($ag.Name -eq $params.AGName) { | ||
$Ensure = "Present" | ||
} | ||
} | ||
} | ||
|
||
return @{ | ||
DatabaseName = $params.DatabaseName | ||
AGName = $AGName | ||
FileShare = $params.FileShare | ||
Ensure = $Ensure | ||
InstallAccount = $params.InstallAccount | ||
} | ||
} | ||
return $result | ||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $DatabaseName, | ||
[parameter(Mandatory = $true)] [System.String] $AGName, | ||
[parameter(Mandatory = $false)] [System.String] $FileShare, | ||
[parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Setting AAG config for $DatabaseName" | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
|
||
# Move to a new AG | ||
if ($CurrentValues.AGName -ne $AGName -and $Ensure -eq "Present") { | ||
Write-Verbose -Message "Moving $DatabaseName from previous AAG to $AGName" | ||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments ($PSBoundParameters, $CurrentValues) -ScriptBlock { | ||
$params = $args[0] | ||
$CurrentValues = $args[1] | ||
|
||
# Remove it from the current AAG first | ||
Remove-DatabaseFromAvailabilityGroup -AGName $CurrentValues.AGName -DatabaseName $params.DatabaseName -Force | ||
|
||
# Now add it to the AAG it's meant to be in | ||
$addParams = @{ | ||
AGName = $params.AGName | ||
DatabaseName = $params.DatabaseName | ||
} | ||
if ($params.ContainsKey("FileShare")) { | ||
$addParams.Add("FileShare", $params.FileShare) | ||
} | ||
Add-DatabaseToAvailabilityGroup @addParams | ||
} | ||
} else { | ||
if ($Ensure -eq "Present") { | ||
# Add to AG | ||
Write-Verbose -Message "Adding $DatabaseName from $AGName" | ||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
$cmdParams = @{ | ||
AGName = $params.AGName | ||
DatabaseName = $params.DatabaseName | ||
} | ||
if ($params.ContainsKey("FileShare")) { | ||
$cmdParams.Add("FileShare", $params.FileShare) | ||
} | ||
Add-DatabaseToAvailabilityGroup @cmdParams | ||
} | ||
} else { | ||
# Remove from the AG | ||
Write-Verbose -Message "Removing $DatabaseName from $AGName" | ||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
Remove-DatabaseFromAvailabilityGroup -AGName $params.AGName -DatabaseName $params.DatabaseName -Force | ||
} | ||
} | ||
} | ||
} | ||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.String] $DatabaseName, | ||
[parameter(Mandatory = $true)] [System.String] $AGName, | ||
[parameter(Mandatory = $false)] [System.String] $FileShare, | ||
[parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
|
||
Write-Verbose -Message "Checking AAG configuration for $DatabaseName" | ||
|
||
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("Ensure", "AGName") | ||
} | ||
|
Oops, something went wrong.