Optimized Compress-Folder and removed New-Folder#952
Merged
Conversation
Didn't need this as we can use New-Item -Force to handle everything that New-Folder basically was. Only losing the fact that we don't call Write-Host, but this isn't required.
Removed some of the old code that didn't need to be there.
bill-long
requested changes
Mar 30, 2022
| Write-Verbose("Creating script block") | ||
| $newFolderScriptBlock = [scriptblock]::Create($newFolderString) | ||
| Write-Verbose("New-Item create Script Block") | ||
| # need to have a blank param to be able to pass an array of 2 folders. |
Member
Member
Author
Member
Member
Author
There was a problem hiding this comment.
After testing it out, I remove the $blank parameter and it does still work but do need to have a fake secondary parameter to pass to the caller. Similar to what you have in the snapshot above. Otherwise, Invoke-Command doesn't know that the array paths need to be going to the 1st parameter. Instead, it would do 1 path to the first parameter, then the second path to the second parameter which doesn't exist and only one path is created.
Use the , instead of a unused parameter to avoid the array from getting unwrapped when passed to the argument list of Invoke-Command.
bill-long
approved these changes
Mar 31, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Reason:
Cleaned up the code on Compress-Folder that wasn't needed.
Removed New-Folder as what it was doing could be handled by New-Item with the Force switch.
Validation:
Tested out in lab.