@@ -143,35 +143,13 @@ class JeaSessionConfiguration
143
143
[Dscproperty ()]
144
144
[int ] $HungRegistrationTimeout = 10
145
145
146
- JeaSessionConfiguration()
147
- {
148
- if (-not $this.SessionType )
149
- {
150
- $this.SessionType = ' RestrictedRemoteServer'
151
- }
152
-
153
- if ($this.RunAsVirtualAccountGroups -and $this.GroupManagedServiceAccount )
154
- {
155
- throw $script :localizedData.ConflictRunAsVirtualAccountGroupsAndGroupManagedServiceAccount
156
- }
157
-
158
- if ($this.GroupManagedServiceAccount -and $this.RunAsVirtualAccount )
159
- {
160
- throw $script :localizedData.ConflictRunAsVirtualAccountAndGroupManagedServiceAccount
161
- }
162
-
163
- if (-not $this.GroupManagedServiceAccount )
164
- {
165
- $this.RunAsVirtualAccount = $true
166
- Write-Warning " 'GroupManagedServiceAccount' and 'RunAsVirtualAccount' are not defined, setting 'RunAsVirtualAccount' to 'true'."
167
- }
168
- }
169
-
170
146
[void ] Set()
171
147
{
172
148
$ErrorActionPreference = ' Stop'
173
149
174
- $psscPath = Join-Path ([IO.Path ]::GetTempPath()) ([IO.Path ]::GetRandomFileName() + " .pssc" )
150
+ $this.TestParameters ()
151
+
152
+ $psscPath = Join-Path ([IO.Path ]::GetTempPath()) ([IO.Path ]::GetRandomFileName() + ' .pssc' )
175
153
Write-Verbose " Storing PSSessionConfigurationFile in file '$psscPath '"
176
154
$desiredState = Convert-ObjectToHashtable - Object $this
177
155
$desiredState.Add (' Path' , $psscPath )
@@ -188,9 +166,9 @@ class JeaSessionConfiguration
188
166
try
189
167
{
190
168
# # If we are replacing Microsoft.PowerShell, create a 'break the glass' endpoint
191
- if ($this.Name -eq " Microsoft.PowerShell" )
169
+ if ($this.Name -eq ' Microsoft.PowerShell' )
192
170
{
193
- $breakTheGlassName = " Microsoft.PowerShell.Restricted"
171
+ $breakTheGlassName = ' Microsoft.PowerShell.Restricted'
194
172
if (-not ($this.GetPSSessionConfiguration ($breakTheGlassName )))
195
173
{
196
174
$this.RegisterPSSessionConfiguration ($breakTheGlassName , $null , $this.HungRegistrationTimeout )
@@ -230,6 +208,8 @@ class JeaSessionConfiguration
230
208
# Tests if the resource is in the desired state.
231
209
[bool ] Test()
232
210
{
211
+ $this.TestParameters ()
212
+
233
213
$currentState = Convert-ObjectToHashtable - Object $this.Get ()
234
214
$desiredState = Convert-ObjectToHashtable - Object $this
235
215
@@ -271,6 +251,32 @@ class JeaSessionConfiguration
271
251
return $compare
272
252
}
273
253
254
+ hidden [bool ] TestParameters()
255
+ {
256
+ if (-not $this.SessionType )
257
+ {
258
+ $this.SessionType = ' RestrictedRemoteServer'
259
+ }
260
+
261
+ if ($this.RunAsVirtualAccountGroups -and $this.GroupManagedServiceAccount )
262
+ {
263
+ throw $script :localizedData.ConflictRunAsVirtualAccountGroupsAndGroupManagedServiceAccount
264
+ }
265
+
266
+ if ($this.GroupManagedServiceAccount -and $this.RunAsVirtualAccount )
267
+ {
268
+ throw $script :localizedData.ConflictRunAsVirtualAccountAndGroupManagedServiceAccount
269
+ }
270
+
271
+ if (-not $this.GroupManagedServiceAccount )
272
+ {
273
+ $this.RunAsVirtualAccount = $true
274
+ Write-Warning " 'GroupManagedServiceAccount' and 'RunAsVirtualAccount' are not defined, setting 'RunAsVirtualAccount' to 'true'."
275
+ }
276
+
277
+ return $true
278
+ }
279
+
274
280
# # Get a PS Session Configuration based on its name
275
281
hidden [object ] GetPSSessionConfiguration($Name )
276
282
{
0 commit comments