Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script for removing worm storage accounts #4959

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

benbp
Copy link
Member

@benbp benbp commented Dec 13, 2022

No description provided.

@benbp benbp requested a review from a team as a code owner December 13, 2022 22:14
@benbp benbp added the Central-EngSys This issue is owned by the Engineering System team. label Dec 13, 2022
@benbp benbp self-assigned this Dec 13, 2022
}
}
if ($PSCmdlet.ShouldProcess($group.ResourceGroupName)) {
Remove-AzResourceGroup -ResourceGroupName $group.ResourceGroupName -Force -AsJob
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm wrapping this instead of just using the native WhatIf because even with WhatIf it still farms it out to a job which can be misleading and make the user think the group is actually being deleted.

if ($PSCmdlet.ShouldProcess($group.ResourceGroupName)) {
Write-Host "Removing $($account.StorageAccountName) in $($account.ResourceGroupName)"
} else {
Write-Host "What if: Removing $($account.StorageAccountName) in $($account.ResourceGroupName)"
Copy link
Member

Choose a reason for hiding this comment

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

I thought the whatif logic in shouddprocess would already output this

Copy link
Member

Choose a reason for hiding this comment

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

Did you want to ship if whatif is set? I see you are still calling remove below.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed it up to just check $WhatIfPreference. The extra stuff from the ShouldProcess log makes the output hard to parse in my opinion.

I still call Remove below because the parent -WhatIf will still pass through to the Az calls and I want those to be part of the whatif logging since it shows each container that would be deleted.

@benbp benbp force-pushed the benbp/remove-worm branch from d68cb65 to 2e7c104 Compare December 16, 2022 19:59
@benbp benbp requested a review from weshaggard December 16, 2022 20:01
@benbp benbp merged commit b4685f9 into Azure:main Jan 18, 2023
@benbp benbp deleted the benbp/remove-worm branch January 18, 2023 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants