DSCResources/xSPAllowSelfServiceUpgrade/xSPAllowSelfServiceUpgrade.psm1
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent $script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' $script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DSCR_MIMSettings.Util' Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'Invoke-SPDscCommand.psm1') function Get-TargetResource { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] param ( [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount, [Parameter(Mandatory = $true)] [System.String] $Site, [Parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) Write-Verbose -Message "Getting AllowSelfServiceUpgrade for Site:$($Site)" $result = Invoke-SPDscCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { $params = $args[0] $Site = get-spite $params.site if ($Site.AllowSelfServiceUpgrade) { return @{ Site = $Site Ensure = "Present" InstallAccount = $params.InstallAccount CurrentValue = $Site.AllowSelfServiceUpgrade } Write-Verbose -Message "Current AllowSelfServiceUpgrade Value is set to $($Site.AllowSelfServiceUpgrade)" } else { return @{ Site = $Site Ensure = "Absent" InstallAccount = $params.InstallAccount CurrentValue = $Site.AllowSelfServiceUpgrade } Write-Verbose -Message "Current AllowSelfServiceUpgrade Value is set to $($Site.AllowSelfServiceUpgrade)" } } return $result } function Set-TargetResource { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [System.String] $Site, [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount, [Parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) $currentValues = Get-TargetResource -Ensure Present -Site $Site if (($CurrentValues.CurrentValue) -and ( $Ensure -eq "Absent")) { Write-Verbose -Message ("AllowSelfServiceUpgrade Not in Desired State, Changing to $false") Invoke-SPDscCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService $contentService.ViewStateOnServer = $False $contentService.Update() } } else { Write-Verbose -Message ("AllowSelfServiceUpgrade, Changing to $true") Invoke-SPDscCommand -Credential $InstallAccount ` -Arguments $PSBoundParameters ` -ScriptBlock { $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService $contentService.ViewStateOnServer = $true $contentService.Update() } } } function Test-TargetResource { [CmdletBinding()] [OutputType([System.Boolean])] param ( [Parameter(Mandatory = $true)] [System.String] $Site, [Parameter()] [System.Management.Automation.PSCredential] $InstallAccount, [Parameter(Mandatory = $true)] [ValidateSet("Present","Absent")] [System.String] $Ensure ) #Write-Verbose "Use this cmdlet to deliver information about command processing." #Write-Debug "Use this cmdlet to write debug information while troubleshooting." <# $result = [System.Boolean] $result #> } Export-ModuleMember -Function *-TargetResource |