Skip to content

Optimized Compress-Folder and removed New-Folder#952

Merged
dpaulson45 merged 3 commits into
mainfrom
dpaul-LogCollectorDev
Mar 31, 2022
Merged

Optimized Compress-Folder and removed New-Folder#952
dpaulson45 merged 3 commits into
mainfrom
dpaul-LogCollectorDev

Conversation

@dpaulson45
Copy link
Copy Markdown
Member

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.

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.
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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for? It looks like you can pass multiple paths directly:

image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For remote execution at the same time within Start-JobManager.

The paths that we need to create are something like this:

image

Start-JobManager is able to kick off multiple jobs against each server and have unique arguments being passed to each server.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't follow. If you want to pass multiple paths:

image

The blank parameter is not needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@dpaulson45 dpaulson45 requested a review from bill-long March 31, 2022 17:09
@dpaulson45 dpaulson45 merged commit 005778b into main Mar 31, 2022
@dpaulson45 dpaulson45 deleted the dpaul-LogCollectorDev branch March 31, 2022 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants