Allow script to be run from any location, add parameter validation, standardize output, remove EFS errors #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The primary reason for this pull request is to allow this script to be run from any location (not just the users "Downloads" folder) and to give the configuration JSON file complete control of the paths for the PEM and credential files, which previously assumed that they were located in the current user profile.
Additionally, per best practices, the use of Write-Host was complete replaced with Write-Verbose, Write-Warning and Write-Error. Terminating usage of Write-Error was replaced with "throw". Both scripts were given parameter inputs to replace the user-interactive prompts. These parameters have help messages, are mandatory and do still prompt if the user fails to specify them, so the end-user experience is similar.
The old VMware PowerCLI snapin was referenced in this script. I have removed this and replaced it with a dependency on the VMware.PowerCLI module.
Finally, the requirement that Encrypting File System be in use is not effective. If the script fails to encrypt files because EFS is not running, the files are still generated and left on disk without encryption. Instead of failing, the script now warns that the files could not be encrypted.