Comments (12)
I am on it.
Will extend this resource with the configuration of the Service App. See https://technet.microsoft.com/EN-US/library/ff608107.aspx for more info. Will post a proposal for the extended structure later.
from sharepointdsc.
hello. I had just started this one too, will check it in anyway as I am almost done with it
from sharepointdsc.
hey @ykuijs I take you are talking about the Set-WordConversionServiceApp parameters, so I will leave this with you :)
from sharepointdsc.
@camiloborges Correct, I was talking about that cmdlet. Since you are already done with the initial resource, go ahead and check it in. Then I can use that as a starting point :-)
from sharepointdsc.
cool, give me 10 minutes to finish unit tests
from sharepointdsc.
https://github.com/camiloborges/xSharePoint/tree/xSPWordAutomationServiceApp
from sharepointdsc.
Did you sync your local copy?? I do not see any resource there?
from sharepointdsc.
hmmm, I had, but I screwed up my brnches
[CmdletBinding()]
param(
[string] $SharePointCmdletModule = (Join-Path $PSScriptRoot "..\Stubs\SharePoint\15.0.4693.1000\Microsoft.SharePoint.PowerShell.psm1" -Resolve)
)
$ErrorActionPreference = 'stop'
Set-StrictMode -Version latest
$RepoRoot = (Resolve-Path $PSScriptRoot....).Path
$Global:CurrentSharePointStubModule = $SharePointCmdletModule
$ModuleName = "MSFT_xSPWordAutomationServiceApp"
Import-Module (Join-Path $RepoRoot "Modules\xSharePoint\DSCResources$ModuleName$ModuleName.psm1")
Describe "xSPWordAutomationServiceApp" {
InModuleScope $ModuleName {
$testParams = @{
Name = "Test Word App"
ApplicationPool = "Test App Pool"
DatabaseName = "WordAutomationn"
}
Import-Module (Join-Path ((Resolve-Path $PSScriptRoot....).Path) "Modules\xSharePoint")
Mock Invoke-xSharePointCommand {
return Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments -NoNewScope
}
Import-Module $Global:CurrentSharePointStubModule -WarningAction SilentlyContinue
Context "When no service applications exist in the current farm" {
Mock Get-SPServiceApplication { return $null }
Mock New-SPWordConversionServiceApplication { }
It "returns null from the Get method" {
Get-TargetResource @testParams | Should BeNullOrEmpty
Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name }
}
It "returns false when the Test method is called" {
Test-TargetResource @testParams | Should Be $false
}
It "creates a new service application in the set method" {
Set-TargetResource @testParams
Assert-MockCalled New-SPWordConversionServiceApplication
}
}
Context "When service applications exist in the current farm but the specific word automation app does not" {
Mock Get-SPServiceApplication { return @(@{
TypeName = "Some other service app type"
}) }
It "returns null from the Get method" {
Get-TargetResource @testParams | Should BeNullOrEmpty
Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name }
}
}
Context "When a service application exists and is configured correctly" {
Mock Get-SPServiceApplication {
return @(@{
TypeName = "Word Automation Services"
DisplayName = $testParams.Name
ApplicationPool = @{ Name = $testParams.ApplicationPool }
})
}
It "returns values from the get method" {
Get-TargetResource @testParams | Should Not BeNullOrEmpty
Assert-MockCalled Get-SPServiceApplication -ParameterFilter { $Name -eq $testParams.Name }
}
It "returns true when the Test method is called" {
Test-TargetResource @testParams | Should Be $true
}
}
Context "When a service application exists and is not configured correctly" {
Mock Get-SPServiceApplication {
return @(@{
TypeName = "Word Automation Services"
DisplayName = $testParams.Name
ApplicationPool = @{ Name = "Wrong App Pool Name" }
})
}
Mock Get-SPServiceApplicationPool { return @{ Name = $testParams.ApplicationPool } }
Mock Set-SPWordConversionServiceApplication {}
It "returns false when the Test method is called" {
Test-TargetResource @testParams | Should Be $false
}
It "calls the update service app cmdlet from the set method" {
Set-TargetResource @testParams
Assert-MockCalled Get-SPServiceApplicationPool
Assert-MockCalled Set-SPWordConversionServiceApplication
}
}
}
}
from sharepointdsc.
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)] [System.String] $Name,
[parameter(Mandatory = $true)] [System.String] $ApplicationPool,
[parameter(Mandatory = $true)] [System.String] $DatabaseName,
[parameter(Mandatory = $false)] [System.String] $DatabaseServer,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)
Write-Verbose -Message "Getting Word Automation service app '$Name'"
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]
$serviceApps = Get-SPServiceApplication -Name $params.Name -ErrorAction SilentlyContinue
if ($null -eq $serviceApps) {
return $null
}
$serviceApp = $serviceApps | Where-Object { $_.TypeName -eq "Word Automation Services" }
If ($null -eq $serviceApp) {
return $null
} else {
$returnVal = @{
Name = $serviceApp.DisplayName
ApplicationPool = $serviceApp.ApplicationPool.Name
DatabaseName = $serviceApp.Databases.Name
DatabaseServer = $serviceApp.Databases.Server.Name
}
return $returnVal
}
}
return $result
}
function Set-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)] [System.String] $Name,
[parameter(Mandatory = $true)] [System.String] $ApplicationPool,
[parameter(Mandatory = $true)] [System.String] $DatabaseName,
[parameter(Mandatory = $false)] [System.String] $DatabaseServer,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)
$result = Get-TargetResource @PSBoundParameters
if ($result -eq $null) {
Write-Verbose -Message "Creating Word Automation Service Application $Name"
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]
if($params.ContainsKey("InstallAccount")){ $params.Remove("InstallAccount")}
New-SPWordConversionServiceApplication @params
}
}
else {
if ($ApplicationPool -ne $result.ApplicationPool) {
Write-Verbose -Message "Updating Word Automation Service Application $Name"
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock {
$params = $args[0]
$appPool = Get-SPServiceApplicationPool -Identity $params.ApplicationPool
Get-SPServiceApplication -Name $params.Name `
| Where-Object { $_.TypeName -eq "Word Automation Services" } `
| Set-SPWordConversionServiceApplication -ApplicationPool $appPool
}
}
}
}
function Test-TargetResource
{
[CmdletBinding()]
[OutputType([System.Boolean])]
param
(
[parameter(Mandatory = $true)] [System.String] $Name,
[parameter(Mandatory = $true)] [System.String] $ApplicationPool,
[parameter(Mandatory = $true)] [System.String] $DatabaseName,
[parameter(Mandatory = $false)] [System.String] $DatabaseServer,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $DatabaseCredentials,
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount
)
Write-Verbose -Message "Testing for Word Automation Service Application '$Name'"
$CurrentValues = Get-TargetResource @PSBoundParameters
if ($null -eq $CurrentValues) { return $false }
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters -ValuesToCheck @("ApplicationPool")
}
Export-ModuleMember -Function *-TargetResource
from sharepointdsc.
Been there, done that :-)
from sharepointdsc.
here we go again, https://github.com/camiloborges/xSharePoint/tree/xSPWordAutomationApp
from sharepointdsc.
note to myself.
will separate 'new' and 'set' parameters with a query
$newPArams = $params.GetEnumerator() | ?{ @("DatabaseName","DatabaseServer","Name", "ApplicationPool" ).Contains($_.Key)}
$setPArams = $params.GetEnumerator() | ?{ @("DatabaseName","DatabaseServer").Contains($_.Key)-eq $false}
from sharepointdsc.
Related Issues (20)
- Pass empty string to parameter HOT 1
- [SPSearchIndexPartition] Regression introduced with with the fix for issue #1376
- [SPProductUpdate] Resource does not support SPSE yet
- [SPProductUpdate] Resource pauses the Search Service
- [SPInstallPrereqs] Multiple instances of the VC++ Redist causes issues
- [SPShellAdmins] Get-SPDatabase cmdlet cannot be found
- [SPConfigWizard] Add possibility to temporarily dismount content databases during config wizard
- SPHybridConfig: New resource proposal HOT 1
- SPTrustedRootAuthority - Error while adding Trusted Root Authority via CertificateThumbprint
- SPInstallPrereqs: sqlncli.msi is no longer required after November 2021 CU HOT 2
- SPPublishServiceApplication - Set-TargetResource does not work
- Issue while exporting the site configurations with certificate thumbprint HOT 2
- [Export] Export doesn't work in SPSE
- [SPFarm] Import-Module SharePointServer causes exception in SharePoint Subscription 23H1 HOT 3
- SPCertificateSettings: Unable to set contacts when previously blank
- Intro and SPSite Enhancement
- DSC Resource HOT 1
- Least-privileged security model enabled after Oct 22 CU
- Visio Graphics Service Application
- SPFarm: Add SPServerCertificatePipeBind Support for the Central Administration with SPSE HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharepointdsc.