PSAppDeployToolkit icon indicating copy to clipboard operation
PSAppDeployToolkit copied to clipboard

Miscellaneous fixes.

Open mjr4077au opened this issue 10 months ago • 0 comments

Variety of fixes that were hard to include unti the release occurred so I could rebase and diff my side compared to yours.

The supply of these fixes, the other two PRs, and the outstanding PowerShell 7 PR effectively eliminate any need I've had for maintaining my own fork.

  • Fix some more variables under strict mode.
    • The variable $installPhase is used by Write-Log before it's defined.
    • The variable $logName is accessed by `Write-Log before it's defined.
    • The variable $defaultMsiExecutablesList is accessed irrespective of whether an MSI operation is underway, so it needs to be available globally, albeit null.
    • The variable $oldPSWindowTitle is accessed in Exit-Script, potentially before its defined.
  • Fix bad variable scoping for $runningProcessDescriptions.
    • The previous setup was breaking strict mode.
  • Ensure $deploymentType is always title-cased for aesthetics.
  • Ensure $deployModeNonInteractive is defined, even for silent mode.
    • It can be accessed in silent modes, but if it doesn't exist this will throw strict mode.
  • Rename Zerotouch to Zero-Config to be consistent with the rest of the log messages.
  • Fix bad call to a Dispose() method, which accepts no parameters.
  • Ensure $installTitle is appropriately trimmed.
    • Variables like $appVendor and $appVersion aren't mandatory, so if they're empty they can leave spaces in $installTitle.
  • Remove dead block of code.
    • Because $configDeferPromptNoDeadline is not defined, this was causing a throw in strict mode. If the block ever triggered, it was also adding a new line for no reason.
  • Fix bad try/catch setup in Get-ServiceStartMode.
    • There was no need for the try/catch setup at all, can simply use a better -ErrorAction value here. This was also causing noise in the $Error global array.
  • Import assemblies earlier in case they're needed within Extensions.
  • Only set $DefaultMstFile and $DefaultMspFiles if they're not already defined.
    • If someone's doing something specific in the Extensions file (i.e. me), they might already be defined ahead of time.

Before submitting this Pull Request, I made sure:

  • [X] I tested the toolkit with my changes and made sure it doesn't break other code.
  • [X] I updated the documentation with the changes I made.
  • [X] The code I changed has comments with explanation.
  • [X] The encoding of the file wasn't changed. It is still UTF8 with BOM.

mjr4077au avatar Mar 28 '24 11:03 mjr4077au