HewlettPackard / POSH-HPEOneView

PowerShell language bindings library for HPE OneView.
http://hewlettpackard.github.io/POSH-HPEOneView/
125 stars 52 forks source link

reset-ovEnclosureDevice should not default to Yes #568

Closed uzimmermann42 closed 2 years ago

uzimmermann42 commented 3 years ago

PS /home/uzimmermann> Reset-OVEnclosureDevice -Enclosure (Get-OVEnclosure -Name syncab4b-2) -Component Device -DeviceID 9 -Efuse

Confirm Are you sure you want to perform this action? Performing the operation "Reset power for device" on target "Device 9 within syncab4b-2". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): n

I really think the default this should be N or L.

ChrisLynchHPE commented 3 years ago

This isn't possible within the built-in SupportsShouldProcess and ConfirmImpact = High Cmdletbinding parameters. This is the same behavior for all other Cmdlets that will cause service outage, or perform other delete operations, including all of the Remove-OV Cmdlets.

uzimmermann42 commented 3 years ago

After further research I have found a way to do this. In order to have a default response set to NO, ShouldContinue Method should be used instead of ShouldProcess.

Reading the documentation https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.cmdlet.shouldcontinue?view=powershellsdk-1.1.0 for ShouldContinue has a section in the format

ShouldContinue(String, String, Boolean, Boolean, Boolean)

The first boolean is to reference a security impact. True if the operation being confirmed has a security impact. If specified, the default option selected in the selection menu is 'No'.

On Mon, Apr 26, 2021 at 12:32 PM Chris Lynch @.***> wrote:

This isn't possible within the built-in SupportsShouldProcess and 'ConfirmImpact = HighCmdletbinding parameters. This is the same behavior for all other Cmdlets that will cause service outage, or perform other deleteoperations, including all of theRemove-OV` Cmdlets.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HewlettPackard/POSH-HPEOneView/issues/568#issuecomment-827090595, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABI4PJQP7JFHMWD2B4Z4HZ3TKW5V3ANCNFSM43PYDKMA .

--

Ulf Zimmermann, 1525 Pacific Ave., Alameda, CA-94501, #: 510-396-1764

ChrisLynchHPE commented 3 years ago

Sorry, but ShouldContinue is not the answer here. While it does offer the ability to prompt the user with different prompts, it does not participate with SupportsShouldProcess decleration. Changing this behavior would require multiple steps and prompts to get to the desired end behavior. And as I stated already, this is the same used in all of the other Cmdlets. Why would this request be limited to just Reset-OVEnclosureDevice?

ChrisLynchHPE commented 2 years ago

Closing due to no further activity. This issue can always be re-opened if needed.