Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/Commands/Files/RemoveFile.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Resources = PnP.PowerShell.Commands.Properties.Resources;
using Microsoft.SharePoint.Client;
using PnP.Framework.Utilities;
using PnP.PowerShell.Commands.Model.SharePoint;
using System.Management.Automation;
using Resources = PnP.PowerShell.Commands.Properties.Resources;

namespace PnP.PowerShell.Commands.Files
{
Expand All @@ -11,29 +11,24 @@ public class RemoveFile : PnPWebCmdlet
{
private const string ParameterSet_SERVER_Delete = "Delete by Server Relative";
private const string ParameterSet_SITE_Delete = "Delete by Site Relative";
private const string ParameterSet_SERVER_Recycle = "Recycle by Server Relative";
private const string ParameterSet_SITE_Recycle = "Recycle by Site Relative";

[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = ParameterSet_SERVER_Delete)]
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = ParameterSet_SERVER_Recycle)]
[ValidateNotNullOrEmpty]
public string ServerRelativeUrl = string.Empty;

[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = ParameterSet_SITE_Delete)]
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = ParameterSet_SITE_Recycle)]
[ValidateNotNullOrEmpty]
public string SiteRelativeUrl = string.Empty;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_SERVER_Recycle)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_SITE_Recycle)]
[Parameter(Mandatory = false)]
public SwitchParameter Recycle;

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

protected override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(ServerRelativeUrl))
if (ParameterSpecified(nameof(SiteRelativeUrl)))
{
var webUrl = CurrentWeb.EnsureProperty(w => w.ServerRelativeUrl);
ServerRelativeUrl = UrlUtility.Combine(webUrl, SiteRelativeUrl);
Expand Down
2 changes: 0 additions & 2 deletions src/Commands/Model/SharePoint/RecycleResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace PnP.PowerShell.Commands.Model.SharePoint
{
Expand Down