protected override void ExecuteCmdlet() { switch (ParameterSetName) { case PARAMETERSET_IDENTITY: var recycleBinItem = Identity.GetRecycleBinItem(ClientContext.Site); if (Force || ShouldContinue(string.Format(Resources.RestoreRecycleBinItem, recycleBinItem.LeafName), Resources.Confirm)) { recycleBinItem.Restore(); ClientContext.ExecuteQueryRetry(); } break; case PARAMETERSET_ALL: #if !SP2013 if (ParameterSpecified(nameof(RowLimit))) { if (Force || ShouldContinue(Resources.RestoreRecycleBinItems, Resources.Confirm)) { RecycleBinItemCollection items = ClientContext.Site.GetRecycleBinItems(null, RowLimit, false, RecycleBinOrderBy.DeletedDate, RecycleBinItemState.None); ClientContext.Load(items); ClientContext.ExecuteQueryRetry(); items.RestoreAll(); ClientContext.ExecuteQueryRetry(); } } else #endif { if (Force || ShouldContinue(Resources.RestoreRecycleBinItems, Resources.Confirm)) { ClientContext.Site.RecycleBin.RestoreAll(); ClientContext.ExecuteQueryRetry(); } } break; } }
protected override void ExecuteCmdlet() { if (ParameterSpecified(nameof(Identity))) { var recycleBinItem = Identity.GetRecycleBinItem(ClientContext.Site); if (Force || ShouldContinue(string.Format(Resources.RestoreRecycleBinItem, recycleBinItem.LeafName), Resources.Confirm)) { recycleBinItem.Restore(); ClientContext.ExecuteQueryRetry(); } } else { if (ParameterSpecified(nameof(RowLimit))) { if (Force || ShouldContinue(Resources.RestoreRecycleBinItems, Resources.Confirm)) { RecycleBinItemCollection items = ClientContext.Site.GetRecycleBinItems(null, RowLimit, false, RecycleBinOrderBy.DeletedDate, RecycleBinItemState.None); ClientContext.Load(items); ClientContext.ExecuteQueryRetry(); items.RestoreAll(); ClientContext.ExecuteQueryRetry(); } } else { if (Force || ShouldContinue(Resources.RestoreRecycleBinItems, Resources.Confirm)) { ClientContext.Site.RecycleBin.RestoreAll(); ClientContext.ExecuteQueryRetry(); } } } }