Skip to content

Commit

Permalink
Feature: Remove confirm switch in favor of Force parameter to make it…
Browse files Browse the repository at this point in the history
… consistent (#4455)

Co-authored-by: Gautam Sheth <[email protected]>
  • Loading branch information
gautamdsheth and Gautam Sheth authored Oct 19, 2024
1 parent f1b45d6 commit 621f1ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/Commands/Graph/RemoveAvailableSiteClassification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ namespace PnP.PowerShell.Commands.Graph
{
[Cmdlet(VerbsCommon.Remove, "PnPAvailableSiteClassification")]
[RequiredApiApplicationPermissions("graph/Directory.ReadWrite.All")]
[Alias("Remove-PnPSiteClassitication")]
[WriteAliasWarning("Please use 'Remove-PnPAvailableSiteClassification'. The alias 'Remove-PnPSiteClassification' will be removed in a future release.")]
[OutputType(typeof(void))]
public class RemoveSiteClassification : PnPGraphCmdlet
{
[Parameter(Mandatory = true)]
public List<string> Classifications;

[Parameter(Mandatory = false)]
public SwitchParameter Confirm;
public SwitchParameter Force;

protected override void ExecuteCmdlet()
{
Expand All @@ -32,7 +30,7 @@ protected override void ExecuteCmdlet()

if (existingSettings.DefaultClassification == classification)
{
if ((ParameterSpecified("Confirm") && !bool.Parse(MyInvocation.BoundParameters["Confirm"].ToString())) || ShouldContinue(string.Format(Properties.Resources.RemoveDefaultClassification0, classification), Properties.Resources.Confirm))
if (Force || ShouldContinue(string.Format(Properties.Resources.RemoveDefaultClassification0, classification), Properties.Resources.Confirm))
{
existingSettings.DefaultClassification = "";
existingSettings.Classifications.Remove(classification);
Expand Down
14 changes: 5 additions & 9 deletions src/Commands/Principals/RemoveUser.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Management.Automation;
using Microsoft.SharePoint.Client;

using System.Linq.Expressions;
using System;
using Microsoft.SharePoint.Client;
using PnP.PowerShell.Commands.Base.PipeBinds;
using System;
using System.Linq.Expressions;
using System.Management.Automation;

namespace PnP.PowerShell.Commands.Principals
{
Expand All @@ -17,9 +16,6 @@ public class RemoveUser : PnPWebCmdlet
[Parameter(Mandatory = false)]
public SwitchParameter Force;

[Parameter(Mandatory = false)]
public SwitchParameter Confirm;

protected override void ExecuteCmdlet()
{
var retrievalExpressions = new Expression<Func<User, object>>[]
Expand All @@ -33,7 +29,7 @@ protected override void ExecuteCmdlet()

if (user != null)
{
if (Force || (ParameterSpecified("Confirm") && !bool.Parse(MyInvocation.BoundParameters["Confirm"].ToString())) || ShouldContinue(string.Format(Properties.Resources.RemoveUser, user.Id, user.LoginName, user.Email), Properties.Resources.Confirm))
if (Force || ShouldContinue(string.Format(Properties.Resources.RemoveUser, user.Id, user.LoginName, user.Email), Properties.Resources.Confirm))
{
WriteVerbose($"Removing user {user.Id} {user.LoginName} {user.Email}");
ClientContext.Web.SiteUsers.Remove(user);
Expand Down

0 comments on commit 621f1ae

Please sign in to comment.