Skip to content

Commit

Permalink
Fix exceptions in Restore-PnPRecycleBinItem
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpoz committed Jan 7, 2025
1 parent ac29068 commit dbe08da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Commands/Base/PipeBinds/RecycleBinItemPipeBind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public RecycleBinItemPipeBind()
public RecycleBinItemPipeBind(RecycleBinItem item)
{
_item = item;
_id = item?.Id;
}

public RecycleBinItemPipeBind(RecycleResult result)
Expand All @@ -31,6 +32,12 @@ public RecycleBinItemPipeBind(RecycleResult result)
public RecycleBinItemPipeBind(IRecycleBinItem result)
{
_recycleBinItem = result;
_id = result?.Id;
}

public RecycleBinItemPipeBind(Guid guid)
{
_id = guid;
}

public RecycleBinItemPipeBind(string id)
Expand Down
5 changes: 5 additions & 0 deletions src/Commands/RecycleBin/RestoreRecycleBinItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ protected override void ExecuteCmdlet()
{
var recycleBinItem = Identity.GetRecycleBinItem(Connection.PnPContext);

if (recycleBinItem == null)
{
throw new PSArgumentException("Recycle bin item not found with the ID specified", nameof(Identity));
}

if (Force || ShouldContinue(string.Format(Resources.RestoreRecycleBinItem, recycleBinItem.LeafName), Resources.Confirm))
{
recycleBinItem.Restore();
Expand Down

0 comments on commit dbe08da

Please sign in to comment.