protected override void ExecuteCmdlet() { if (MyInvocation.BoundParameters.ContainsKey("List")) { var list = List.GetList(SelectedWeb); WriteObject(list.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); } else { WriteObject(SelectedWeb.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); } }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); var d = new { ManualRecordDeclaration = list.GetListManualRecordDeclaration(), AutoRecordDeclaration = list.GetListAutoRecordDeclaration() }; WriteObject(d); }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); list.EnsureProperty(l => l.RootFolder); var result = DocumentSet.Create(ClientContext, list.RootFolder, Name, ContentType.GetContentType(SelectedWeb).Id); ClientContext.ExecuteQueryRetry(); WriteObject(result.Value); }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); var item = Identity.GetListItem(list); var returnValue = Microsoft.SharePoint.Client.RecordsRepository.Records.IsRecord(ClientContext, item); ClientContext.ExecuteQueryRetry(); WriteObject(returnValue.Value); }
protected override void ExecuteCmdlet() { if (ParameterSpecified(nameof(List))) { var list = List.GetList(SelectedWeb); WriteObject(list.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); } else { WriteObject(SelectedWeb.AddRemoteEventReceiver(Name, Url, EventReceiverType, Synchronization, SequenceNumber, Force)); } }
protected override void ExecuteCmdlet() { List list = null; if (List != null) { list = List.GetList(SelectedWeb); } if (list != null) { ListItemCreationInformation liCI = new ListItemCreationInformation(); var item = list.AddItem(liCI); if (ContentType != null) { ContentType ct = null; if (ContentType.ContentType == null) { if (ContentType.Id != null) { ct = SelectedWeb.GetContentTypeById(ContentType.Id, true); } else if (ContentType.Name != null) { ct = SelectedWeb.GetContentTypeByName(ContentType.Name, true); } } else { ct = ContentType.ContentType; } if (ct != null) { ct.EnsureProperty(w => w.StringId); item["ContentTypeId"] = ct.StringId; item.Update(); ClientContext.ExecuteQueryRetry(); } } foreach (var key in Values.Keys) { item[key as string] = Values[key]; } item.Update(); ClientContext.Load(item); ClientContext.ExecuteQueryRetry(); WriteObject(item); } }
protected override void ExecuteCmdlet() { var list = List.GetList(PnPContext); if (list != null) { list.SetComplianceTag(string.Empty, false, false, SyncToItems); } else { WriteWarning("List or library not found."); } }
protected override void ExecuteCmdlet() { #if !SP2013 DefaultRetrievalExpressions = new Expression <Func <Folder, object> >[] { f => f.ServerRelativeUrl, f => f.Name, f => f.TimeLastModified, f => f.ItemCount }; #else DefaultRetrievalExpressions = new Expression <Func <Folder, object> >[] { f => f.ServerRelativeUrl, f => f.Name, f => f.ItemCount }; #endif if (List != null) { // Gets the provided list var list = List.GetList(SelectedWeb); // Query for all folders in the list CamlQuery query = CamlQuery.CreateAllFoldersQuery(); do { // Execute the query. It will retrieve all properties of the folders. Refraining to using the RetrievalExpressions would cause a tremendous increased load on SharePoint as it would have to execute a query per list item which would be less efficient, especially on lists with many folders, than just getting all properties directly ListItemCollection listItems = list.GetItems(query); ClientContext.Load(listItems, item => item.Include(t => t.Folder), item => item.ListItemCollectionPosition); ClientContext.ExecuteQueryRetry(); // Take all the folders from the resulting list items and put them in a list to return var folders = new List <Folder>(listItems.Count); foreach (ListItem listItem in listItems) { var folder = listItem.Folder; folders.Add(folder); } WriteObject(folders, true); query.ListItemCollectionPosition = listItems.ListItemCollectionPosition; } while (query.ListItemCollectionPosition != null); } else { var webServerRelativeUrl = SelectedWeb.EnsureProperty(w => w.ServerRelativeUrl); if (!Url.StartsWith(webServerRelativeUrl, StringComparison.OrdinalIgnoreCase)) { Url = UrlUtility.Combine(webServerRelativeUrl, Url); } #if ONPREMISES var folder = SelectedWeb.GetFolderByServerRelativeUrl(Url); #else var folder = SelectedWeb.GetFolderByServerRelativePath(ResourcePath.FromDecodedUrl(Url)); #endif folder.EnsureProperties(RetrievalExpressions); WriteObject(folder); } }
protected override void ExecuteCmdlet() { List list = null; if (List != null) { list = List.GetList(CurrentWeb); } if (list != null) { if (list.BaseTemplate == (int)ListTemplateType.DocumentLibrary || list.BaseTemplate == (int)ListTemplateType.WebPageLibrary || list.BaseTemplate == (int)ListTemplateType.PictureLibrary) { Field field = null; // Get the field if (Field.Field != null) { field = Field.Field; ClientContext.Load(field); ClientContext.ExecuteQueryRetry(); field.EnsureProperties(f => f.TypeAsString, f => f.InternalName); } else if (Field.Id != Guid.Empty) { field = list.Fields.GetById(Field.Id); ClientContext.Load(field, f => f.InternalName, f => f.TypeAsString); ClientContext.ExecuteQueryRetry(); } else if (!string.IsNullOrEmpty(Field.Name)) { field = list.Fields.GetByInternalNameOrTitle(Field.Name); ClientContext.Load(field, f => f.InternalName, f => f.TypeAsString); ClientContext.ExecuteQueryRetry(); } if (field != null) { IDefaultColumnValue defaultColumnValue = field.GetDefaultColumnValueFromField(ClientContext, Folder, Value); list.SetDefaultColumnValues(new List <IDefaultColumnValue>() { defaultColumnValue }); } } else { WriteWarning("List is not a document library"); } } }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); if (ManualRecordDeclaration.HasValue) { list.SetListManualRecordDeclaration(ManualRecordDeclaration.Value); } if (AutoRecordDeclaration.HasValue) { list.SetListAutoRecordDeclaration(AutoRecordDeclaration.Value); } }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); if (Identity != null) { var item = Identity.GetListItem(list); if (Force || ShouldContinue(string.Format(Properties.Resources.RemoveListItemWithId0, item.Id), Properties.Resources.Confirm)) { item.DeleteObject(); ClientContext.ExecuteQueryRetry(); } } }
protected override void ExecuteCmdlet() { if (Identity != null) { var list = Identity.GetList(SelectedWeb); WriteObject(list); } else { var lists = ClientContext.LoadQuery(SelectedWeb.Lists.IncludeWithDefaultProperties(l => l.Id, l => l.BaseTemplate, l => l.OnQuickLaunch, l => l.DefaultViewUrl, l => l.Title, l => l.Hidden, l => l.RootFolder.ServerRelativeUrl)); ClientContext.ExecuteQueryRetry(); WriteObject(lists, true); } }
protected override void ExecuteCmdlet() { var list = List.GetList(PnPContext); if (list == null) { throw new PSArgumentException($"Cannot find list provided through -{nameof(List)}", nameof(List)); } var item = Identity.GetListItem(list); if (item == null) { throw new PSArgumentException($"Cannot find list item provided through -{nameof(Identity)}", nameof(Identity)); } var commentsCollection = item.GetCommentsAsync().GetAwaiter().GetResult(); var commentsEnumerable = commentsCollection.AsRequested(); if (All.IsPresent) { if (Force || ShouldContinue($"Remove all list item comments?", Resources.Confirm)) { var commentsList = commentsEnumerable.ToList(); for (int i = commentsList.Count - 1; i >= 0; i--) { commentsList[i].Delete(); } } } else { if (string.IsNullOrEmpty(Text)) { throw new PSArgumentException($"Comment Text must contain a value", nameof(Text)); } var commentToBeDeleted = commentsEnumerable.Where(t => t.Text == Text).FirstOrDefault(); if (commentToBeDeleted != null) { if (Force || ShouldContinue($"Remove list item comment?", Resources.Confirm)) { commentToBeDeleted.Delete(); } } } }
protected override void ExecuteCmdlet() { List list = null; if (List != null) { list = List.GetList(SelectedWeb); } if (list != null) { var view = list.CreateView(Title, ViewType, Fields, RowLimit, SetAsDefault, Query, Personal); WriteObject(view); } }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); if (list == null) { throw new PSArgumentException($"No list found with id, title or url '{List}'", "List"); } var item = Identity.GetListItem(list); Microsoft.SharePoint.Client.RecordsRepository.Records.UndeclareItemAsRecord(ClientContext, item); ClientContext.ExecuteQueryRetry(); }
protected override void ExecuteCmdlet() { if (Identity != null) { var list = Identity.GetList(SelectedWeb); if (list != null) { if (Force || ShouldContinue(Properties.Resources.RemoveList, Properties.Resources.Confirm)) { list.DeleteObject(); ClientContext.ExecuteQueryRetry(); } } } }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); var item = Identity.GetListItem(list); if (!MyInvocation.BoundParameters.ContainsKey("DeclarationDate")) { Microsoft.SharePoint.Client.RecordsRepository.Records.DeclareItemAsRecord(ClientContext, item); } else { Microsoft.SharePoint.Client.RecordsRepository.Records.DeclareItemAsRecordWithDeclarationDate(ClientContext, item, DeclarationDate); } ClientContext.ExecuteQueryRetry(); }
protected override void ExecuteCmdlet() { var list = List.GetList(PnPContext); if (list == null) { throw new PSArgumentException($"Cannot find list provided through -{nameof(List)}", nameof(List)); } var item = Identity.GetListItem(list); if (item == null) { throw new PSArgumentException($"Cannot find list item provided through -{nameof(Identity)}", nameof(Identity)); } var commentsCollection = item.GetCommentsAsync().GetAwaiter().GetResult(); var comments = commentsCollection.AsRequested(); var commentsList = new List <ListItemComments>(); if (comments != null) { foreach (var comment in comments) { var commentValue = new ListItemComments { Author = comment.Author, CreatedDate = comment.CreatedDate, Id = comment.Id, IsLikedByUser = comment.IsLikedByUser, IsReply = comment.IsReply, ItemId = comment.ItemId, LikeCount = comment.LikeCount, ListId = comment.ListId, ParentId = comment.ParentId, ReplyCount = comment.ReplyCount, Text = comment.Text }; commentsList.Add(commentValue); } WriteObject(commentsList, true); } }
protected override void ExecuteCmdlet() { if (List != null) { var list = List.GetList(CurrentWeb); if (list != null) { var keys = list.GetIndexedPropertyBagKeys(); WriteObject(keys); } } else { var keys = CurrentWeb.GetIndexedPropertyBagKeys(); WriteObject(keys); } }
protected override void ExecuteCmdlet() { var list = List.GetList(CurrentWeb); if (list == null) { throw new PSArgumentException($"No list found with id, title or url '{List}'", "List"); } var item = Identity.GetListItem(list); var returnValue = Microsoft.SharePoint.Client.RecordsRepository.Records.IsRecord(ClientContext, item); ClientContext.ExecuteQueryRetry(); WriteObject(returnValue.Value); }
protected override void ExecuteCmdlet() { if (List != null) { var list = List.GetList(SelectedWeb); if (list == null) { throw new PSArgumentException($"No list found with id, title or url '{List}'", "List"); } if (string.IsNullOrEmpty(Name)) { var servicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb); var subscriptionService = servicesManager.GetWorkflowSubscriptionService(); var subscriptions = subscriptionService.EnumerateSubscriptionsByList(list.Id); ClientContext.Load(subscriptions); ClientContext.ExecuteQueryRetry(); WriteObject(subscriptions, true); } else { WriteObject(list.GetWorkflowSubscription(Name)); } } else { if (string.IsNullOrEmpty(Name)) { var servicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb); var subscriptionService = servicesManager.GetWorkflowSubscriptionService(); var subscriptions = subscriptionService.EnumerateSubscriptions(); ClientContext.Load(subscriptions); ClientContext.ExecuteQueryRetry(); WriteObject(subscriptions, true); } else { WriteObject(SelectedWeb.GetWorkflowSubscription(Name)); } } }
protected override void ExecuteCmdlet() { if (!string.IsNullOrEmpty(Key)) { if (List != null) { var list = List.GetList(SelectedWeb); if (list != null) { list.AddIndexedPropertyBagKey(Key); } } else { SelectedWeb.AddIndexedPropertyBagKey(Key); } } }
protected override void ExecuteCmdlet() { if (!string.IsNullOrEmpty(Key)) { if (List != null) { var list = List.GetList(CurrentWeb); if (list != null) { list.RemoveIndexedPropertyBagKey(Key); } } else { CurrentWeb.RemoveIndexedPropertyBagKey(Key); } } }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); if (list != null) { var view = list.CreateView(Title, ViewType, Fields, RowLimit, SetAsDefault, Query, Personal, Paged); if (ParameterSpecified(nameof(Aggregations))) { view.Aggregations = Aggregations; view.Update(); list.Context.Load(view); list.Context.ExecuteQueryRetry(); } WriteObject(view); } }
protected override void ExecuteCmdlet() { Field f; if (List != null) { List list = List.GetList(SelectedWeb); f = list.CreateField(FieldXml); } else { f = SelectedWeb.CreateField(FieldXml); } ClientContext.Load(f); ClientContext.ExecuteQueryRetry(); WriteObject(f); }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); if (list == null) { throw new PSArgumentException($"No list found with id, title or url '{List}'", "List"); } if (Identity != null) { var item = Identity.GetListItem(list); if (Force || ShouldContinue(string.Format(Properties.Resources.MoveListItemWithId0ToRecycleBin, item.Id), Properties.Resources.Confirm)) { item.Recycle(); ClientContext.ExecuteQueryRetry(); } } }
protected override void ExecuteCmdlet() { List list = null; if (List != null) { list = List.GetList(SelectedWeb); } var alert = new AlertCreationInformation(); User user; if (null != User) { user = User.GetUser(ClientContext); if (user == null) { throw new ArgumentException("Unable to find user", "Identity"); } } else { user = SelectedWeb.CurrentUser; } user.EnsureProperty(u => u.Alerts.IncludeWithDefaultProperties(a => a.ListID)); if (list != null && !string.IsNullOrWhiteSpace(Title)) { WriteObject(user.Alerts.Where(l => l.ListID == list.Id && l.Title == Title), true); } else if (list != null) { WriteObject(user.Alerts.Where(l => l.ListID == list.Id), true); } else if (!string.IsNullOrWhiteSpace(Title)) { WriteObject(user.Alerts.Where(l => l.Title == Title), true); } else { WriteObject(user.Alerts, true); } }
protected override void ExecuteCmdlet() { DefaultRetrievalExpressions = new Expression <Func <List, object> >[] { l => l.Id, l => l.BaseTemplate, l => l.OnQuickLaunch, l => l.DefaultViewUrl, l => l.Title, l => l.Hidden, l => l.RootFolder.ServerRelativeUrl }; if (Identity != null) { var list = Identity.GetList(SelectedWeb); list?.EnsureProperties(RetrievalExpressions); WriteObject(list); } else { var query = SelectedWeb.Lists.IncludeWithDefaultProperties(RetrievalExpressions); var lists = ClientContext.LoadQuery(query); ClientContext.ExecuteQueryRetry(); WriteObject(lists, true); } }
protected override void ExecuteCmdlet() { if (List != null) { var list = List.GetList(SelectedWeb); if (string.IsNullOrEmpty(Name)) { var servicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb); var subscriptionService = servicesManager.GetWorkflowSubscriptionService(); var subscriptions = subscriptionService.EnumerateSubscriptionsByList(list.Id); ClientContext.Load(subscriptions); ClientContext.ExecuteQueryRetry(); WriteObject(subscriptions, true); } else { WriteObject(list.GetWorkflowSubscription(Name)); } } else { if (string.IsNullOrEmpty(Name)) { var servicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb); var subscriptionService = servicesManager.GetWorkflowSubscriptionService(); var subscriptions = subscriptionService.EnumerateSubscriptions(); ClientContext.Load(subscriptions); ClientContext.ExecuteQueryRetry(); WriteObject(subscriptions, true); } else { WriteObject(SelectedWeb.GetWorkflowSubscription(Name)); } } }
protected override void ExecuteCmdlet() { var list = List.GetList(CurrentWeb); if (list == null) { throw new PSArgumentException($"No list found with id, title or url '{List}'", "List"); } var item = Identity.GetListItem(list); if (!ParameterSpecified(nameof(DeclarationDate))) { Microsoft.SharePoint.Client.RecordsRepository.Records.DeclareItemAsRecord(ClientContext, item); } else { Microsoft.SharePoint.Client.RecordsRepository.Records.DeclareItemAsRecordWithDeclarationDate(ClientContext, item, DeclarationDate); } ClientContext.ExecuteQueryRetry(); }