Skip to content

Commit

Permalink
Added Remote Desktop parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
raandree committed Feb 24, 2022
1 parent 85ffed6 commit 99a62e6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
21 changes: 18 additions & 3 deletions doc/ComputerSettings.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DscConfig.Demo YAML Reference: ComputerSettings
// CommonTasks YAML Reference: ComputerSettings
// ============================================

:YmlCategory: ComputerSettings
Expand All @@ -15,10 +15,11 @@

[cols="1,3a" options="autowidth" caption=]
|===
| Source | https://github.com/dsccommunity/DscConfig.Demo/tree/main/source/DSCResources/ComputerSettings
| Source | https://github.com/dsccommunity/CommonTasks/tree/main/source/DSCResources/ComputerSettings
| DSC Resource | https://github.com/dsccommunity/ComputerManagementDsc[ComputerManagementDsc]
| Documentation | https://github.com/dsccommunity/ComputerManagementDsc/wiki/Computer[Computer],
https://github.com/dsccommunity/ComputerManagementDsc/wiki/TimeZone[TimeZone]
https://github.com/dsccommunity/ComputerManagementDsc/wiki/TimeZone[TimeZone],
https://github.com/dsccommunity/ComputerManagementDsc/wiki/RemoteDesktopAdmin[RemoteDesktopAdmin]
|===


Expand Down Expand Up @@ -73,6 +74,18 @@
| Specifies the TimeZone. +
| Use `Get-TimeZone -ListAvailable \| Format-Table` to get valid time zone strings.

| AllowRemoteDesktop
|
| Bool
| Enables or disabled remote desktop. +
|

| RemoteDesktopUserAuthentication
|
| String
| Configures the authentication for remote desktop. +
| Secure, Unsecure

|===

.Example
Expand All @@ -84,4 +97,6 @@ ComputerSettings:
DomainName: Contoso
Credential: '[ENC=PE9ianMgVmVyc2lvbj0i...=]'
TimeZone: Fiji Standard Time
AllowRemoteDesktop: true
RemoteDesktopUserAuthentication: Secure
----
38 changes: 32 additions & 6 deletions source/DSCResources/ComputerSettings/ComputerSettings.schema.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ configuration ComputerSettings {

[Parameter()]
[string]
$TimeZone
$TimeZone,

[Parameter()]
[bool]$AllowRemoteDesktop,

[Parameter()]
[ValidateSet('Secure', 'NonSecure')]
[string]$RemoteDesktopUserAuthentication
)

Import-DscResource -ModuleName PSDesiredStateConfiguration
Expand All @@ -42,11 +49,30 @@ configuration ComputerSettings {
}
(Get-DscSplattedResource -ResourceName Computer -ExecutionName "Computer$($params.Name)" -Properties $params -NoInvoke).Invoke($params)

$params = @{ }
foreach ($item in ($PSBoundParameters.GetEnumerator() | Where-Object Key -In $timeZoneParamList))
if ($TimeZone)
{
$params.Add($item.Key, $item.Value)
$params = @{ }
foreach ($item in ($PSBoundParameters.GetEnumerator() | Where-Object Key -In $timeZoneParamList))
{
$params.Add($item.Key, $item.Value)
}
$params.Add('IsSingleInstance', 'Yes')
(Get-DscSplattedResource -ResourceName TimeZone -ExecutionName "TimeZone$($params.Name)" -Properties $params -NoInvoke).Invoke($params)
}

if ($RemoteDesktopUserAuthentication)
{
$params = @{ }
$params.IsSingleInstance = 'Yes'
$params.UserAuthentication = $RemoteDesktopUserAuthentication
if ($AllowRemoteDesktop)
{
$params.Ensure = 'Present'
}
else
{
$params.Ensure = 'Absent'
}
(Get-DscSplattedResource -ResourceName RemoteDesktopAdmin -ExecutionName "RemoteDesktopAdmin$($params.Name)" -Properties $params -NoInvoke).Invoke($params)
}
$params.Add('IsSingleInstance', 'Yes')
(Get-DscSplattedResource -ResourceName TimeZone -ExecutionName "TimeZone$($params.Name)" -Properties $params -NoInvoke).Invoke($params)
}

0 comments on commit 99a62e6

Please sign in to comment.