@@ -165,20 +165,22 @@ function Test-TargetResource
165165
166166 $currentValues = Get-TargetResource @PSBoundParameters
167167 if ($Ensure -ne $currentValues.Ensure ) { return $false }
168- if ($TaskPath -ne $currentValues.TaskPath ) { return $false }
169- if ($ActionExecutable -ne $currentValues.ActionExecutable ) { return $false }
170- if (($PSBoundParameters.ContainsKey (" ActionArguments" ) -eq $true ) -and ($ActionArguments -ne $currentValues.ActionArguments )) { return $false }
171- if (($PSBoundParameters.ContainsKey (" ActionWorkingPath" ) -eq $true ) -and ($ActionWorkingPath -ne $currentValues.ActionWorkingPath )) { return $false }
172- if ($ScheduleType -ne $currentValues.ScheduleType ) { return $false }
173- if ($RepeatInterval -ne $currentValues.RepeatInterval ) { return $false }
174-
175- if ($PSBoundParameters.ContainsKey (" ExecuteAsCredential" ) -eq $true ) {
176- if ($ExecuteAsCredential.UserName.Contains (' \' ) -eq $true ) {
177- $localUser = $ExecuteAsCredential.UserName.Split (' \' )[1 ]
178- } else {
179- $localUser = $ExecuteAsCredential.UserName
168+ if ($Ensure -eq " Present" ) {
169+ if ($TaskPath -ne $currentValues.TaskPath ) { return $false }
170+ if ($ActionExecutable -ne $currentValues.ActionExecutable ) { return $false }
171+ if (($PSBoundParameters.ContainsKey (" ActionArguments" ) -eq $true ) -and ($ActionArguments -ne $currentValues.ActionArguments )) { return $false }
172+ if (($PSBoundParameters.ContainsKey (" ActionWorkingPath" ) -eq $true ) -and ($ActionWorkingPath -ne $currentValues.ActionWorkingPath )) { return $false }
173+ if ($ScheduleType -ne $currentValues.ScheduleType ) { return $false }
174+ if ($RepeatInterval -ne $currentValues.RepeatInterval ) { return $false }
175+
176+ if ($PSBoundParameters.ContainsKey (" ExecuteAsCredential" ) -eq $true ) {
177+ if ($ExecuteAsCredential.UserName.Contains (' \' ) -eq $true ) {
178+ $localUser = $ExecuteAsCredential.UserName.Split (' \' )[1 ]
179+ } else {
180+ $localUser = $ExecuteAsCredential.UserName
181+ }
182+ if ($localUser -ne $currentValues.ExecuteAsCredential ) { return $false }
180183 }
181- if ($localUser -ne $currentValues.ExecuteAsCredential ) { return $false }
182184 }
183185
184186 return $true
0 commit comments