@@ -143,7 +143,7 @@ function Convert-ADTDeployment
143143
144144 $variableReplacements = @ (' appVendor' , ' appName' , ' appVersion' , ' appArch' , ' appLang' , ' appRevision' , ' appScriptVersion' , ' appScriptAuthor' , ' installName' , ' installTitle' , ' appSuccessExitCodes' , ' appRebootExitCodes' , ' appProcessesToClose' , ' requireAdmin' , ' deployAppScriptFriendlyName' , ' deployAppScriptVersion' )
145145
146- $customRulePath = [System.IO.Path ]::Combine($MyInvocation.MyCommand.Module.ModuleBase , ' PSScriptAnalyzer\Measure-ADTCompatibility.psm1' )
146+ $customRulePath = [System.IO.Path ]::Combine($MyInvocation.MyCommand.Module.ModuleBase , ' PSScriptAnalyzer\Measure-ADTCompatibility.psm1' )
147147 }
148148
149149 process
@@ -320,31 +320,31 @@ function Convert-ADTDeployment
320320 # Get the text form of the hashtable definition
321321 $hashtableContent = $hashtableAst.Right.Extent.Text
322322
323- # Copy each variable value from the input script to the hashtable
324- foreach ($variableReplacement in $variableReplacements )
325- {
326- $assignmentAst = $inputScriptAst.Find ({
327- param ($ast )
328- $ast -is [System.Management.Automation.Language.AssignmentStatementAst ] -and $ast.Left.Extent.Text -match " ^(\[[^\]]+\])?\`$ (adtSession\.)?$variableReplacement $"
329- }, $true )
330-
331- if ($assignmentAst )
323+ # Copy each variable value from the input script to the hashtable
324+ foreach ($variableReplacement in $variableReplacements )
332325 {
333- Write-Verbose - Message " Updating variable [$variableReplacement ]"
334- $variableValue = $assignmentAst.Right.Extent.Text
335- $hashtableContent = $hashtableContent -replace " (?m)(^\s*$variableReplacement \s*=)\s*'[^']*'" , " `$ 1 $variableValue "
326+ $assignmentAst = $inputScriptAst.Find ({
327+ param ($ast )
328+ $ast -is [System.Management.Automation.Language.AssignmentStatementAst ] -and $ast.Left.Extent.Text -match " ^(\[[^\]]+\])?\`$ (adtSession\.)?$variableReplacement $"
329+ }, $true )
330+
331+ if ($assignmentAst )
332+ {
333+ Write-Verbose - Message " Updating variable [$variableReplacement ]"
334+ $variableValue = $assignmentAst.Right.Extent.Text
335+ $hashtableContent = $hashtableContent -replace " (?m)(^\s*$variableReplacement \s*=)\s*'[^']*'" , " `$ 1 $variableValue "
336+ }
336337 }
337- }
338338
339339 Write-Verbose - Message ' Updating variable [appScriptDate]'
340340 $hashtableContent = $hashtableContent -replace " (?m)(^\s*appScriptDate\s*=)\s*'[^']+'" , " `$ 1 '$ ( Get-Date - Format " yyyy-MM-dd" ) '"
341341
342- # Update the content of the v4 template script
343- $start = $hashtableAst.Right.Extent.StartOffset
344- $end = $hashtableAst.Right.Extent.EndOffset
345- $scriptContent = $tempScriptAst.Extent.Text
346- $newScriptContent = ($scriptContent.Substring (0 , $start ) + $hashtableContent + $scriptContent.Substring ($end )).Trim()
347- Set-Content - Path $outputScriptPath - Value $newScriptContent - Encoding UTF8
342+ # Update the content of the v4 template script
343+ $start = $hashtableAst.Right.Extent.StartOffset
344+ $end = $hashtableAst.Right.Extent.EndOffset
345+ $scriptContent = $tempScriptAst.Extent.Text
346+ $newScriptContent = ($scriptContent.Substring (0 , $start ) + $hashtableContent + $scriptContent.Substring ($end )).Trim()
347+ Set-Content - Path $outputScriptPath - Value $newScriptContent - Encoding UTF8
348348 }
349349 else
350350 {
0 commit comments