@@ -50,22 +50,30 @@ function Invoke-ModuleUpgradeStep
5050 - StartOffset $Step.SourceCommand.StartOffset - EndOffset $Step.SourceCommand.EndOffset
5151
5252 # replacement code
53- $null = $FileContent.Remove ($Step.SourceCommand.StartOffset , ($Step.SourceCommand.EndOffset - $Step.SourceCommand.StartOffset ));
54- $null = $FileContent.Insert ($Step.SourceCommand.StartOffset , $Step.Replacement );
53+ $null = $FileContent.Remove ($Step.SourceCommand.StartOffset , ($Step.SourceCommand.EndOffset - $Step.SourceCommand.StartOffset ))
54+ $null = $FileContent.Insert ($Step.SourceCommand.StartOffset , $Step.Replacement )
5555 }
5656 " CmdletParameter"
5757 {
58- Write-Verbose - Message (" [{0}] Updating CmdletParameter {1} to {2}." `
59- -f $Step.Location , $Step.Original , $Step.Replacement )
58+ if ([System.String ]::IsNullOrWhiteSpace($Step.Replacement ) -eq $false )
59+ {
60+ Write-Verbose - Message (" [{0}] Updating CmdletParameter {1} to {2}." `
61+ -f $Step.Location , $Step.Original , $Step.Replacement )
6062
61- # safety check
62- # ensure that the file offsets are an exact match.
63- Confirm-StringBuilderSubstring - FileContent $FileContent - Substring $Step.Original `
64- - StartOffset $Step.SourceCommandParameter.StartOffset - EndOffset $Step.SourceCommandParameter.EndOffset
63+ # safety check
64+ # ensure that the file offsets are an exact match.
65+ Confirm-StringBuilderSubstring - FileContent $FileContent - Substring $Step.Original `
66+ - StartOffset $Step.SourceCommandParameter.StartOffset - EndOffset $Step.SourceCommandParameter.EndOffset
6567
66- # replacement code
67- $null = $FileContent.Remove ($Step.SourceCommandParameter.StartOffset , ($Step.SourceCommandParameter.EndOffset - $Step.SourceCommandParameter.StartOffset ));
68- $null = $FileContent.Insert ($Step.SourceCommandParameter.StartOffset , $Step.Replacement );
68+ # replacement code
69+ $null = $FileContent.Remove ($Step.SourceCommandParameter.StartOffset , ($Step.SourceCommandParameter.EndOffset - $Step.SourceCommandParameter.StartOffset ))
70+ $null = $FileContent.Insert ($Step.SourceCommandParameter.StartOffset , $Step.Replacement )
71+ }
72+ else
73+ {
74+ Write-Verbose - Message (" [{0}] Skipping CmdletParameter {1}, it has no automated replacement." `
75+ -f $Step.Location , $Step.Original )
76+ }
6977 }
7078 default
7179 {
0 commit comments