DSCResources/myAdExchPrepareSchema/myAdExchPrepareSchema.psm1
Import-Module $PSScriptRoot\..\myAdHelper.psm1 -Verbose:$false function Get-TargetResource { param ( [parameter(Mandatory = $true)] [System.String]$ExchSchemaVersion, [Parameter(Mandatory = $true)] [System.String]$Path, [System.String]$Arguments, [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential]$Credential ) $Schema = ReplacePartitionTokens -Identity "%%schema%%" -Credential $Credential myGetAdObject -Identity "CN=ms-Exch-Schema-Version-Pt,$Schema" -Credential $Credential -Properties @('rangeUpper') } function Set-TargetResource { [CmdletBinding()] param ( [parameter(Mandatory = $true)] [System.String]$ExchSchemaVersion, [Parameter(Mandatory = $true)] [System.String]$Path, [System.String]$Arguments, [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential]$Credential ) StartAndWaitWaitForProcessEnd -Path $Path -Arguments $Arguments -Credential $Credential -Delay 7200 -Verbose -TaskName 'EXCHANGE - PrepareSchema' -ProcessToWaitFor 'ExSetup*' } function Test-TargetResource { [CmdletBinding()] [OutputType([System.Boolean])] param ( [parameter(Mandatory = $true)] [System.String]$ExchSchemaVersion, [Parameter(Mandatory = $true)] [System.String]$Path, [System.String]$Arguments, [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential]$Credential ) $Result = $true $Version = Get-TargetResource @PSBoundParameters if ($Version) { if ([uint32]$Version.rangeUpper -lt [uint32]$ExchSchemaVersion) { $Result = $false } } else { $Result = $false } $result } Export-ModuleMember -Function *-TargetResource |