Skip to content

OpenSSHUtils.psm1 Uses Non-standard "Quiet" Switch Name (and non-standard Functionality) for PowerShell standard "Confirm" Switch #749

Closed
@DarwinJS

Description

@DarwinJS

The -Quiet switch in OpenSSHUtils.psm1 appear to be functioning in ways that mimic the standard "Confirm" switch of PowerShell (example:

if (-not $Quiet) {
$warning = "Current owner: '$($acl.Owner)'. '$($Owners[0])' should own $FilePath."
Do {
Write-Warning $warning
$input = Read-Host -Prompt "Shall I set the file owner? [Yes] Y; [No] N (default is `"Y`")"
if([string]::IsNullOrEmpty($input))
{
$input = 'Y'
}
} until ($input -match "^(y(es)?|N(o)?)$")
$result = $Matches[0]
}
)

The standard way is to use "SupportsShouldProcess" in the CMDLET binding

However, I personally do not like the degraded readability and what seems like some counter-intuitive logic in my code when I put the actual code changes to support "SupportsShouldProcess".

In this case I would probably cheat and just add a parameter "Confirm". Also this approach would be able to retain your timeout - which I like and I believe is NOT part of standard ShouldProcess support.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions