@@ -6,12 +6,8 @@ enum Ensure
6
6
7
7
$modulePath = Join-Path - Path (Split-Path - Path (Split-Path - Path $PSScriptRoot - Parent) - Parent) - ChildPath Modules
8
8
9
- # Import the JeaDsc Common Module
10
- Import-Module - Name (Join-Path - Path $modulePath `
11
- - ChildPath (Join-Path - Path JeaDsc.Common `
12
- - ChildPath JeaDsc.Common.psm1))
13
-
14
9
Import-Module - Name (Join-Path - Path $modulePath - ChildPath DscResource.Common)
10
+ Import-Module - Name (Join-Path - Path $modulePath - ChildPath (Join-Path - Path JeaDsc.Common - ChildPath JeaDsc.Common.psm1))
15
11
16
12
$script :localizedData = Get-LocalizedData - DefaultUICulture en- US
17
13
@@ -26,11 +22,11 @@ class JeaSessionConfiguration
26
22
[DscProperty (Key)]
27
23
[string ] $Name = ' Microsoft.PowerShell'
28
24
29
- # # The mandatory role definition map to be used for the endpoint. This
25
+ # # The role definition map to be used for the endpoint. This
30
26
# # should be a string that represents the Hashtable used for the RoleDefinitions
31
27
# # property in New-PSSessionConfigurationFile, such as:
32
28
# # RoleDefinitions = '@{ Everyone = @{ RoleCapabilities = "BaseJeaCapabilities" } }'
33
- [Dscproperty (Mandatory )]
29
+ [Dscproperty ()]
34
30
[string ] $RoleDefinitions
35
31
36
32
# # run the endpoint under a Virtual Account
@@ -177,14 +173,14 @@ class JeaSessionConfiguration
177
173
178
174
$psscPath = Join-Path ([IO.Path ]::GetTempPath()) ([IO.Path ]::GetRandomFileName() + " .pssc" )
179
175
Write-Verbose " Storing PSSessionConfigurationFile in file '$psscPath '"
180
- $parameters = Convert-ObjectToHashtable - Object $this
181
- $parameters .Add (' Path' , $psscPath )
176
+ $desiredState = Convert-ObjectToHashtable - Object $this
177
+ $desiredState .Add (' Path' , $psscPath )
182
178
183
179
if ($this.Ensure -eq [Ensure ]::Present)
184
180
{
185
- foreach ($parameter in $parameters .Keys.Where ( { $parameters [$_ ] -match ' @{' }))
181
+ foreach ($parameter in $desiredState .Keys.Where ( { $desiredState [$_ ] -match ' @{' }))
186
182
{
187
- $parameters [$parameter ] = Convert-StringToObject - InputString $parameters [$parameter ]
183
+ $desiredState [$parameter ] = Convert-StringToObject - InputString $desiredState [$parameter ]
188
184
}
189
185
}
190
186
@@ -211,8 +207,8 @@ class JeaSessionConfiguration
211
207
{
212
208
# # Create the configuration file
213
209
# New-PSSessionConfigurationFile @configurationFileArguments
214
- $parameters = Sync-Parameter - Command (Get-Command - Name New-PSSessionConfigurationFile ) - Parameters $parameters
215
- New-PSSessionConfigurationFile @parameters
210
+ $desiredState = Sync-Parameter - Command (Get-Command - Name New-PSSessionConfigurationFile ) - Parameters $desiredState
211
+ New-PSSessionConfigurationFile @desiredState
216
212
217
213
# # Register the configuration file
218
214
$this.RegisterPSSessionConfiguration ($this.Name , $psscPath , $this.HungRegistrationTimeout )
@@ -235,12 +231,12 @@ class JeaSessionConfiguration
235
231
[bool ] Test()
236
232
{
237
233
$currentState = Convert-ObjectToHashtable - Object $this.Get ()
238
- $parameters = Convert-ObjectToHashtable - Object $this
234
+ $desiredState = Convert-ObjectToHashtable - Object $this
239
235
240
236
# short-circuit if the resource is not present and is not supposed to be present
241
- if ($currentState.Ensure -ne $parameters .Ensure )
237
+ if ($currentState.Ensure -ne $desiredState .Ensure )
242
238
{
243
- Write-Verbose " Desired state of session configuration named '$ ( $currentState.Name ) ' is '$ ( $parameters .Ensure ) ', current state is '$ ( $currentState.Ensure ) ' "
239
+ Write-Verbose " Desired state of session configuration named '$ ( $currentState.Name ) ' is '$ ( $desiredState .Ensure ) ', current state is '$ ( $currentState.Ensure ) ' "
244
240
return $false
245
241
}
246
242
if ($this.Ensure -eq [Ensure ]::Absent)
@@ -255,22 +251,22 @@ class JeaSessionConfiguration
255
251
}
256
252
257
253
$cmdlet = Get-Command - Name New-PSSessionConfigurationFile
258
- $parameters = Sync-Parameter - Command $cmdlet - Parameters $parameters
254
+ $desiredState = Sync-Parameter - Command $cmdlet - Parameters $desiredState
259
255
$currentState = Sync-Parameter - Command $cmdlet - Parameters $currentState
260
256
$propertiesAsObject = $cmdlet.Parameters.Keys |
261
- Where-Object { $_ -in $parameters .Keys } |
257
+ Where-Object { $_ -in $desiredState .Keys } |
262
258
Where-Object { $cmdlet.Parameters .$_.ParameterType.FullName -in ' System.Collections.IDictionary' , ' System.Collections.Hashtable' , ' System.Collections.IDictionary[]' , ' System.Object[]' }
263
259
foreach ($p in $propertiesAsObject )
264
260
{
265
261
if ($cmdlet.Parameters .$p.ParameterType.FullName -in ' System.Collections.Hashtable' , ' System.Collections.IDictionary' , ' System.Collections.IDictionary[]' , ' System.Object[]' )
266
262
{
267
- $parameters ." $ ( $p ) " = $parameters ." $ ( $p ) " | Convert-StringToObject
263
+ $desiredState ." $ ( $p ) " = $desiredState ." $ ( $p ) " | Convert-StringToObject
268
264
$currentState ." $ ( $p ) " = $currentState ." $ ( $p ) " | Convert-StringToObject
269
265
270
266
}
271
267
}
272
268
273
- $compare = Test-DscParameterState2 - CurrentValues $currentState - DesiredValues $parameters - TurnOffTypeChecking - SortArrayValues - ReverseCheck
269
+ $compare = Test-DscParameterState - CurrentValues $currentState - DesiredValues $desiredState - TurnOffTypeChecking - SortArrayValues - ReverseCheck
274
270
275
271
return $compare
276
272
}
0 commit comments