Modules/RemoteDesktopServicesDsc.Common/RemoteDesktopServicesDsc.Common.psm1
|
#Region '.\prefix.ps1' -1 $script:dscResourceCommonModulePath = Join-Path -Path $PSScriptRoot -ChildPath '../DscResource.Common' Import-Module -Name $script:dscResourceCommonModulePath $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' #EndRegion '.\prefix.ps1' 6 #Region '.\Public\Get-RemoteDesktopServicesDscOsVersion.ps1' -1 function Get-RemoteDesktopServicesDscOsVersion { [CmdletBinding()] [OutputType([System.Version])] param () return [Environment]::OSVersion.Version } #EndRegion '.\Public\Get-RemoteDesktopServicesDscOsVersion.ps1' 9 #Region '.\Public\Import-RemoteDesktopModule.ps1' -1 <# .SYNOPSIS Ensures the RDMS service is running and imports the RemoteDesktop CDXML module globally. .DESCRIPTION The RemoteDesktop module is a CDXML module whose proxy commands are generated at import time. When DSC runs inside wmiprvse.exe, Import-Module defaults to function scope, so the proxy commands are not visible to the calling DSC resource. This function starts the RDMS service (required for the WMI namespace the CDXML module connects to) and imports the module with -Global so the commands are available in all scopes. .INPUTS None .OUTPUTS None .EXAMPLE Import-RemoteDesktopModule Starts the RDMS service if it is not running and imports the RemoteDesktop module into the global scope so that its commands are available to DSC resources. #> function Import-RemoteDesktopModule { [CmdletBinding()] [OutputType()] param () $rdmsService = Get-Service -Name RDMS -ErrorAction SilentlyContinue if ($null -ne $rdmsService -and $rdmsService.Status -ne 'Running') { Start-Service -Name RDMS -ErrorAction Stop $rdmsService.WaitForStatus('Running', [TimeSpan]::FromSeconds(30)) } if (-not (Get-Module -Name RemoteDesktop)) { Import-Module -Name RemoteDesktop -Global -Force -ErrorAction Stop } } #EndRegion '.\Public\Import-RemoteDesktopModule.ps1' 46 #Region '.\Public\Test-RemoteDesktopServicesDscOsRequirement.ps1' -1 <# .SYNOPSIS Verifies that the operating system meets the Remote Desktop st requirement. .DESCRIPTION Returns $true when Get-RemoteDesktopServicesDscOsVersion reports at least Windows Server 2012 (6.2.9200.0); otherwise returns $false. .OUTPUTS System.Boolean Indicates whether the OS version is supported. .EXAMPLE Test-RemoteDesktopServicesDscOsRequirement Returns $true if the OS is Windows Server 2012 or later, otherwise $false. #> function Test-RemoteDesktopServicesDscOsRequirement { [CmdletBinding()] [OutputType([System.Boolean])] param () return (Get-RemoteDesktopServicesDscOsVersion) -ge ([System.Version]::new(6, 2, 9200, 0)) } #EndRegion '.\Public\Test-RemoteDesktopServicesDscOsRequirement.ps1' 27 |