Skip to content

Add should process support for remove d365database#881

Merged
FH-Inway merged 10 commits intod365collaborative:masterfrom
FH-Inway:add-should-process-support-for-remove-d365database
Mar 8, 2025
Merged

Add should process support for remove d365database#881
FH-Inway merged 10 commits intod365collaborative:masterfrom
FH-Inway:add-should-process-support-for-remove-d365database

Conversation

@FH-Inway
Copy link
Member

This pull request introduces several enhancements to the Remove-D365Database function and its usage in the New-D365Bacpac function. The key changes include adding new parameters to improve user control and updating documentation and tests accordingly.

fixes #879

Enhancements to Remove-D365Database function:

  • Added -Confirm, -WhatIf, and -Force parameters to Remove-D365Database to provide better control over command execution and user confirmation. (d365fo.tools/functions/remove-d365database.ps1, [1] [2] [3]
  • Updated the function to support ShouldProcess for high-impact actions, ensuring users are prompted for confirmation before executing critical steps. (d365fo.tools/functions/remove-d365database.ps1, d365fo.tools/functions/remove-d365database.ps1R89-R99)

Updates to New-D365Bacpac function:

  • Modified calls to Remove-D365Database to include -Confirm:$false, bypassing confirmation prompts during automated processes. (d365fo.tools/functions/new-d365bacpac.ps1, [1] [2]

Documentation updates:

  • Updated Remove-D365Database documentation to include descriptions and usage examples for the new -Confirm, -WhatIf, and -Force parameters. (docs/Remove-D365Database.md, [1] [2]

Testing enhancements:

@FH-Inway
Copy link
Member Author

@Splaxi This will break Remove-D365Database for existing users that do not expect a confirmation prompt when running the command.

My guess is not many are using this command and its main use is as part of New-D365Bacpac, where the confirmation prompt is suppressed.

One alternative I can think of (well, besides just not making the change) is to lower the ConfirmImpact to Medium. This would result in no prompt unless someone sets the $ConfirmationPreference to Medium (default is High). This would probably not have prevented #879 even if advise is added to the ReadMe to run d365fo.tools with Medium ConfirmationPreference while one gets familiar with it.

@Splaxi
Copy link
Collaborator

Splaxi commented Mar 1, 2025

I would like to go beyond and above to avoid breaking changes.

So let's handle the level and test things

FH-Inway and others added 6 commits March 2, 2025 13:34
With default PowerShell setting of High for $ConfirmPreference, this will not result in a confirmation prompt when executing the cmdlet. This prevents a breaking change.

d365collaborative#879
This pull request was automatically created by the d365fo.tools-Generate-Text action'
@FH-Inway
Copy link
Member Author

FH-Inway commented Mar 2, 2025

Alright, I changed the impact level to Medium. In turn, I added some documentation and console messages to make the impact of the command clearer.
Also fixed some minor issues with the command.

New behavior looks like this:

PS C:\Repositories\GitHub\FH-Inway\d365fo.tools> $OriginalConfirmPreference = $ConfirmPreference
PS C:\Repositories\GitHub\FH-Inway\d365fo.tools> $ConfirmPreference = "Medium"
PS C:\Repositories\GitHub\FH-Inway\d365fo.tools> Remove-D365Database -DatabaseName "AxDW"

Confirm
Are you sure you want to perform this action?
Performing the operation "Kill all processes" on target "AxDW".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): L
PS C:\Repositories\GitHub\FH-Inway\d365fo.tools> $ConfirmPreference = $OriginalConfirmPreference
PS C:\Repositories\GitHub\FH-Inway\d365fo.tools> Remove-D365Database -DatabaseName "AxDW"
[14:11:33][Remove-D365Database] Database AxDW was removed.
PS C:\Repositories\GitHub\FH-Inway\d365fo.tools> Remove-D365Database
[14:11:51][Remove-D365Database] Database AxDB was removed.
PS C:\Repositories\GitHub\FH-Inway\d365fo.tools> Remove-D365Database
WARNING: [14:17:18][Remove-D365Database] Database AxDB not found. Nothing to remove.

image

@FH-Inway FH-Inway merged commit 9c29374 into d365collaborative:master Mar 8, 2025
5 checks passed
@FH-Inway FH-Inway deleted the add-should-process-support-for-remove-d365database branch April 26, 2025 15:45
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.

Improvement that Remove-D365Database does require explicitly confirmation that AxDB is to be removed

2 participants