Skip to content

Commit

Permalink
Merge pull request #85 from PowerShell/dev
Browse files Browse the repository at this point in the history
Merging for release of v0.7
  • Loading branch information
KarolKaczmarek committed Oct 15, 2015
2 parents 7390379 + 420d65f commit 34ff4a8
Show file tree
Hide file tree
Showing 87 changed files with 47,275 additions and 3,036 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.suo
*.user
*.user
*.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,37 @@ function Get-TargetResource
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[System.String]
$Name,

[parameter(Mandatory = $true)]
[System.String]
$ApplicationPool,

[parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$InstallAccount
[parameter(Mandatory = $true)] [System.String] $Name,
[parameter(Mandatory = $true)] [System.String] $ApplicationPool,
[parameter(Mandatory = $false)] [System.String] $DatabaseName,
[parameter(Mandatory = $false)] [System.String] $DatabaseServer,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)

Write-Verbose -Message "Getting BCS service app '$Name'"

$session = Get-xSharePointAuthenticatedPSSession -Credential $InstallAccount

$result = Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock {
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]
$serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue |
Where-Object { $_.TypeName -eq "Business Data Connectivity Service Application" }
If ($null -eq $serviceApp)
{
return @{}

$serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue
if ($null -eq $serviceApps) {
return $null
}
else
{
return @{
$serviceApp = $serviceApps | Where-Object { $_.TypeName -eq "Business Data Connectivity Service Application" }

If ($null -eq $serviceApp) {
return $null
} else {
$returnVal = @{
Name = $serviceApp.DisplayName
ApplicationPool = $serviceApp.ApplicationPool.Name
DatabaseName = $serviceApp.Database.Name
DatabaseServer = $serviceApp.Database.Server.Name
InstallAccount = $params.InstallAccount
}
return $returnVal
}
}
$result
return $result
}


Expand All @@ -46,45 +43,39 @@ function Set-TargetResource
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[System.String]
$Name,

[parameter(Mandatory = $true)]
[System.String]
$ApplicationPool,

[parameter(Mandatory = $true)]
[System.String]
$DatabaseName,

[parameter(Mandatory = $true)]
[System.String]
$DatabaseServer,

[parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$InstallAccount
[parameter(Mandatory = $true)] [System.String] $Name,
[parameter(Mandatory = $true)] [System.String] $ApplicationPool,
[parameter(Mandatory = $false)] [System.String] $DatabaseName,
[parameter(Mandatory = $false)] [System.String] $DatabaseServer,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)

$result = Get-TargetResource -Name $Name -ApplicationPool $ApplicationPool -InstallAccount $InstallAccount
$session = Get-xSharePointAuthenticatedPSSession -Credential $InstallAccount
$result = Get-TargetResource @PSBoundParameters

if ($result.Count -eq 0) {
Write-Verbose -Message "Creating BCS Service Application $Name"
Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock {
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]
$params.Remove("InstallAccount") | Out-Null
New-SPBusinessDataCatalogServiceApplication @params | Out-Null


New-SPBusinessDataCatalogServiceApplication -Name $params.Name `
-ApplicationPool $params.ApplicationPool `
-DatabaseName $params.DatabaseName `
-DatabaseServer $params.DatabaseServer
}
}
else {
if ($ApplicationPool -ne $result.ApplicationPool) {
Write-Verbose -Message "Updating BCS Service Application $Name"
Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock {
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]
$serviceApp = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue |
Where-Object { $_.TypeName -eq "Business Data Connectivity Service Application" }
$serviceApp | Set-SPBusinessDataCatalogServiceApplication -ApplicationPool (Get-SPServiceApplicationPool $params.ApplicationPool)


$appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool

Get-SPServiceApplication -Name $params.Name `
| Where-Object { $_.TypeName -eq "Business Data Connectivity Service Application" } `
| Set-SPBusinessDataCatalogServiceApplication -ApplicationPool $appPool
}
}
}
Expand All @@ -96,34 +87,18 @@ function Test-TargetResource
[OutputType([System.Boolean])]
param
(
[parameter(Mandatory = $true)]
[System.String]
$Name,

[parameter(Mandatory = $true)]
[System.String]
$ApplicationPool,

[parameter(Mandatory = $true)]
[System.String]
$DatabaseName,

[parameter(Mandatory = $true)]
[System.String]
$DatabaseServer,

[parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$InstallAccount
[parameter(Mandatory = $true)] [System.String] $Name,
[parameter(Mandatory = $true)] [System.String] $ApplicationPool,
[parameter(Mandatory = $false)] [System.String] $DatabaseName,
[parameter(Mandatory = $false)] [System.String] $DatabaseServer,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)
$result = Get-TargetResource -Name $Name -ApplicationPool $ApplicationPool -InstallAccount $InstallAccount

Write-Verbose -Message "Testing for BCS Service Application '$Name'"
if ($result.Count -eq 0) { return $false }
else {
if ($ApplicationPool -ne $result.ApplicationPool) { return $false }
}
return $true
$CurrentValues = Get-TargetResource @PSBoundParameters

if ($null -eq $CurrentValues) { return $false }
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool")
}

Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class MSFT_xSPBCSServiceApp : OMI_BaseResource
[Required] String ApplicationPool;
[Write] string DatabaseName;
[Write] String DatabaseServer;
[Required, EmbeddedInstance("MSFT_Credential")] String InstallAccount;
[Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount;
};

Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,38 @@ function Get-TargetResource
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[System.String]
$WebAppUrl,

[parameter(Mandatory = $true)]
[System.String]
$SuperUserAlias,

[parameter(Mandatory = $true)]
[System.String]
$SuperReaderAlias,

[parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$InstallAccount
[parameter(Mandatory = $true)] [System.String] $WebAppUrl,
[parameter(Mandatory = $true)] [System.String] $SuperUserAlias,
[parameter(Mandatory = $true)] [System.String] $SuperReaderAlias,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)

Write-Verbose -Message "Getting cache accounts for $WebAppUrl"

$session = Get-xSharePointAuthenticatedPSSession -Credential $InstallAccount

$result = Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock {
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]
$wa = Get-SPWebApplication $params.WebAppUrl -ErrorAction SilentlyContinue


$wa = Get-SPWebApplication -Identity $params.WebAppUrl -ErrorAction SilentlyContinue

if ($null -eq $wa) { return @{} }
if ($null -eq $wa) { return $null }

$returnVal = @{}
$returnVal.Add("WebAppUrl", $params.WebAppUrl)
if ($wa.Properties.ContainsKey("portalsuperuseraccount")) {
$returnVal.Add("portalsuperuseraccount", $wa.Properties["portalsuperuseraccount"])
$returnVal.Add("SuperUserAlias", $wa.Properties["portalsuperuseraccount"])
} else {
$returnVal.Add("portalsuperuseraccount", "")
$returnVal.Add("SuperUserAlias", "")
}
if ($wa.Properties.ContainsKey("portalsuperreaderaccount")) {
$returnVal.Add("portalsuperreaderaccount", $wa.Properties["portalsuperreaderaccount"])
$returnVal.Add("SuperReaderAlias", $wa.Properties["portalsuperreaderaccount"])
} else {
$returnVal.Add("portalsuperreaderaccount", "")
$returnVal.Add("SuperReaderAlias", "")
}

$returnVal.Add("InstallAccount", $params.InstallAccount)
return $returnVal
}
$result
return $result
}


Expand All @@ -55,32 +44,21 @@ function Set-TargetResource
[CmdletBinding()]
param
(
[parameter(Mandatory = $true)]
[System.String]
$WebAppUrl,

[parameter(Mandatory = $true)]
[System.String]
$SuperUserAlias,

[parameter(Mandatory = $true)]
[System.String]
$SuperReaderAlias,

[parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$InstallAccount
[parameter(Mandatory = $true)] [System.String] $WebAppUrl,
[parameter(Mandatory = $true)] [System.String] $SuperUserAlias,
[parameter(Mandatory = $true)] [System.String] $SuperReaderAlias,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)

Write-Verbose -Message "Setting cache accounts for $WebAppUrl"

$session = Get-xSharePointAuthenticatedPSSession -Credential $InstallAccount

$result = Invoke-Command -Session $session -ArgumentList $PSBoundParameters -ScriptBlock {

$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]

$wa = Get-SPWebApplication $params.WebAppUrl
$wa = Get-SPWebApplication -Identity $params.WebAppUrl -ErrorAction SilentlyContinue
if ($null -eq $wa) {
throw [Exception] "The web applications $($params.WebAppUrl) can not be found to set cache accounts"
}

if ($wa.Properties.ContainsKey("portalsuperuseraccount")) {
$wa.Properties["portalsuperuseraccount"] = $params.SuperUserAlias
Expand All @@ -92,6 +70,15 @@ function Set-TargetResource
} else {
$wa.Properties.Add("portalsuperreaderaccount", $params.SuperReaderAlias)
}

$readPolicy = $wa.Policies.Add($params.SuperReaderAlias, $params.SuperReaderAlias)
$readPolicyRole = $wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead)
$readPolicy.PolicyRoleBindings.Add($readPolicyRole)

$policy = $wa.Policies.Add($params.SuperUserAlias, $params.SuperUserAlias)
$policyRole = $wa.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl)
$policy.PolicyRoleBindings.Add($policyRole)

$wa.Update()
}
}
Expand All @@ -103,32 +90,16 @@ function Test-TargetResource
[OutputType([System.Boolean])]
param
(
[parameter(Mandatory = $true)]
[System.String]
$WebAppUrl,

[parameter(Mandatory = $true)]
[System.String]
$SuperUserAlias,

[parameter(Mandatory = $true)]
[System.String]
$SuperReaderAlias,

[parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$InstallAccount
[parameter(Mandatory = $true)] [System.String] $WebAppUrl,
[parameter(Mandatory = $true)] [System.String] $SuperUserAlias,
[parameter(Mandatory = $true)] [System.String] $SuperReaderAlias,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)

$result = Get-TargetResource -WebAppUrl $WebAppUrl -SuperUserAlias $SuperUserAlias -SuperReaderAlias $SuperReaderAlias -InstallAccount $InstallAccount
$CurrentValues = Get-TargetResource @PSBoundParameters
Write-Verbose -Message "Testing cache accounts for $WebAppUrl"

if ($result.Count -eq 0) { return $false }
else {
if ($SuperUserAlias -ne $result.portalsuperuseraccount) { return $false }
if ($SuperReaderAlias -ne $result.portalsuperreaderaccount) { return $false }
}
return $true
if ($null -eq $CurrentValues) {return $false }
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("SuperUserAlias", "SuperReaderAlias")
}

Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class MSFT_xSPCacheAccounts : OMI_BaseResource
[Key] string WebAppUrl;
[Required] string SuperUserAlias;
[Required] string SuperReaderAlias;
[Required, EmbeddedInstance("MSFT_Credential")] String InstallAccount;
[Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount;
};

0 comments on commit 34ff4a8

Please sign in to comment.