One line Powershell to delete all list items?
Is it possible to have one line powershell to delete all items in a list (no folders)?
I tried this one from
http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/de844268-6bb5-4510-9c83-bbca24cf278f,
$list.get_items() | where { $_.column name with spaces -like '3*' } | % { $_.Delete() }.
In my case, I remove the middle part: $list.get_items() | % { $_.Delete() }
I got one item removed with the exception:
An error occurred while enumerating through a collection: Collection was modifi
ed; enumeration operation may not execute..
At line:1 char:1
+ <<<< $list.Get_Items() | % {$_.Delete()}
+ CategoryInfo : InvalidOperation: (Microsoft.Share...on+SPEnumer
ator:SPEnumerator) [], RuntimeException
+ FullyQualifiedErrorId : BadEnumeration
Seems I am missing some here - I am running Powershell through SharePoint 2010 Management Shell as Administrator.
this happens because after you delete the first item, the original collection is modified.
You can do a simple while to delete all items:
while($list.Items.Count -gt 0){$list.Items.Delete(0)}
Hope this could help.
Similar Messages
-
Error: "The workflow could not delete the list item"
Have set up 2 lists: Events and EventsArchive. They have all the same fields. I have created a workflow in SPD using an impersonation step (I have Full control of the site/site collection). Workflow is essentially this:
If Curent Item:Expired
equals
Yes
Copy item in Current Item to
EventsArchive
then Delete item in
Current Item.
The item is copying over to the EventsArchive list just fine, but the "delete" part is not happening. Instead, I get the following error:
The workflow could not delete the list item. Make sure the list exists and the user has permissions to delete items in the list.
The list obviously exists (or I wouldn't be able to copy an item from it), and I have as much permissions as anyone can have, so I'm not sure where else to turn with this.
Thanks in advance for your help!Hi,
To test the issue, I create a simple workflow without using Impersonation step:
It works.
Could you please create new lists to avoid custom settings and test the issue again?
Similar thread:
https://social.msdn.microsoft.com/Forums/office/en-US/3fa94026-4487-4e4c-a5b4-12a79d6ee6a2/workflow-delete-item-not-working?forum=sharepointcustomizationprevious
Regards,
Rebecca Tu
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
How to delete a list-item with Contribute 4
I use Contribute for a lot of my client for years and a few
weeks ago i installed Contribute 4 for the first time for a new
client .We dicovered that it's difficult or impossible to delete a
list-item in a unordered list. Maybe also in other list-types but
we haven't tried this yet. Does anybody know how to delete a
list-item? In Contribute 3 you just had to use the backspace button
but that isn't working anymore.
Thanks for your help.
Maarten Strik
www.strikdesign.nlhttp://linesofcode.net/snippets/166
-
how do you reduce the size of the email storage on an iPhone? I have deleted all mail items and my mailbox still takes up 1.2 GB of space.
What is the Other on my iPhone and How to Remove It
Also
"First you go settings/general/usage/music/then left swipe over music and press delete and you would think it deletes your music but it doesn't instead it deletes your other but make sure your ipod is connected to a computer while doing this"
as recommended by:
How do I get rid of "other" storage: Apple Support Communities
Next, usually restoring from backup eliminated the corrupted files. However, sometimes restoring to factory settings/new iPod is required.
To restore from backup see:
iOS: How to back up
To restore to factory settings/new iPod see:
iTunes: Restoring iOS software -
How to delete a list item in Sharepoint 2007 via SOAP?
I am looking to delete a list item using soap web services. I am using the Lists.asmx web service.
The XML looks like this:
<Batch OnError="Continue" ListVersion="1">
<Method ID="1" Cmd="Delete">
<Field Name="ID">7</Field>
</Method>
</Batch>
I got this from the msdn docs at http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems%28v=office.12%29.aspx
And I am using the Lists.UpdateListItems Method.
I am doing this in python and python has a library, suds for this purpose. However I get this exception:
suds.WebFault: Server raised fault: 'Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.'
I have looked for typos, and verified the XML format. Where am I going wrong?
Some help please.http://linesofcode.net/snippets/166
-
What is the best approach to delete multiple list items
Hi
I want to delete multiple list items at once, what is best approach please suggest?
RameshHi Ramesh,
Better approach for removing many items from a list is to use the ProcessBatchData method provided by the SPWeb class. First, you need a collection of the list items
you want to remove, and then you can use the Get-SPListItem function to retrieve a list of items that match a given criteria. Then build a batch string with resultant items and call the ProcessBatchData method.
Here is the sample code.
function Get-SPList($webUrl, $lstUrl)
$webObj = Get-SPWeb -identity $webUrl
$lstObj = $webObj.GetList($lstUrl);
return $lstObj
$spList = Get-SPList -webUrl "http://mysitecollecton/MySite" -lstUrl "http://mysitecollecton/MySite/Lists/EmpInfo"
$spQuery = new-object Microsoft.SharePoint.SPQuery
$camlQuery =
"<Where>
<Eq>
<FieldRef Name='Department' />
<Value Type='Text'>HR</Value>
</Eq>
</Where>"
$spQuery.Query = $camlQuery
$spQuery.RowLimit = 100
$spListItemCollection = $spList.GetItems($spQuery)
# Create batch remove CAML query
$batchRemove = '<?xml version="1.0" encoding="UTF-8"?><Batch>';
# The command is used for each list item retrieved
$command = '<Method><SetList Scope="Request">' +
$spList.ID +'</SetList><SetVar Name="ID">{0}</SetVar>' +
'<SetVar Name="Cmd">Delete</SetVar></Method>';
foreach ($item in $spListItemCollection)
$batchRemove += $command -f $item.Id;
$batchRemove += "</Batch>";
# Remove the list items using the batch command
$spList.ParentWeb.ProcessBatchData($batchRemove) | Out-Null
Please don't forget to mark it answered, if your problem resolved or helpful. -
How can I delete a list item entry based on date? Nintex workflow?
I have a list with two columns. One of the columns in the list has a training date. I would like to delete entries in the list after the date has passed. How can I do this?
Should I create a Nintex workflow to run everyday? What operation in Nintex would I use to check the date in the list and then delete an entry if the current date has come?Murugesa,
I have access to SharePoint Designer and also Nintex. Are you suggesting I use SharePoint Designer instead of Nintex? I have not used visual studio much so my knowledge with it is not good.
You can create the simple workflow using visual studio. Drag and drop the IF else activity and Code activity to delete the item.
Inside code activity event, Retrieve your date column value and compare against your logic date. if list column value passed then code activity executes the deletion.
Option 2:
If you have SPD design permission on your site,you can simply wire the same logic in the out of box workflow GUI level.
Murugesa Pandian.,MCTS|App.Devleopment|Configure -
On the previous version of FF the All-in-One side bar showed my Bookmarks OK. Upgrading to FF4 has lost them all, except a recent one, from the sidebar. However they are available from the drop-down via the Firefox button at top left. Then when I go to 'show all bookmarks' the only one shown is the recent one. Saving the bookmarks results in that single one being saved only! Deleting all the bookmarks and re-installing a backup results in the same happening, they list ok on the dropdown but not in the side bar. Any ideas?
This can be caused by a problem with the file places.sqlite that stores the bookmarks and the history.
* http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
* http://kb.mozillazine.org/Bookmarks_not_saved -
Deleting a List Item with Very Huge Amount of Versions
A faulty workflow flooded list items with 50K+ versions on SharePoint List. Attempts to open the list item/delete/edit via SharePoint UI/PowerShell failed! Programmatic iterations to delete versions/items trys to consume complete server memory and
fails.
Deleting the complete list is successful, but that results in SharePoint timer jobs fail and places Lots of Block in the database, which stops SharePoint sites from loading.
Any help please?SP 2010 and 2013 support a max of 50,000 versions. Accessing more than 5000 items at a time causes SQL Server to escalate from row locks to table locks, which will generally bring SharePoint to a stop. You will need to write code that can bring back subsets
of the data, and the only approach I can think of is a CAML query. But, I can't find any examples of working with versions using CAML.
You could just change the Throttling settings in Central Admin from the default of 5000 to 50000 and then run your code during off hours.
Mike Smith TechTrainingNotes.blogspot.com
Books:
SharePoint 2007 2010 Customization for the Site Owner,
SharePoint 2010 Security for the Site Owner -
Hello people,
I have a datablock where one of the items is a check box. I would like to know how to delete all items that has been selected by the checkbox. At the moment I use 'delete_record' but that only deletes the first selected row.
thank you in advance!Try something like:
GO_BLOCK('CMC_REPORTS');
First_Record;
-- loop through the block until you reach the last record
WHILE :SYSTEM.LAST_RECORD = 'FALSE' LOOP
IF :CMC_REPORTS.ndb_delete_rec = 'Y' THEN
delete_record;
ELSE
Next_Record;
END IF;
END LOOP;
-- check to see if the last record needs to be deleted
IF :CMC_REPORTS.ndb_delete_rec = 'Y' THEN
delete_record;
END IF;
-- check to see if deletes need to be commited
IF :SYSTEM.FORM_STATUS = 'CHANGED' THEN
commit_form;
END IF;
DO_KEY('EXECUTE_QUERY'); -
At work I use a PowerMac G4 AGP with OSX 10.3. I accidentally dragged and dropped 1000+ documents onto the desktop. Is there any way to automatically delete every item on the desktop? The machine won't respond to any commands, (apple+A to select them all and delete them, etc.) beacause the performance is slowed down after login by all these items. Any suggestions?
Mike,
It sounds like you have a couple of options. Maybe you would like to follow up on Ed's suggestion.
If you want to follow Kurt's suggestion and move the files with unix commands, I can tell you a little more about dealing with files that do not have extensions. The trick in this business is that the * character is a wildcard. So, if you issue the command
mv *.jpg ~/Desktop/temp/
that will move all files which have the extension jpg and anything before the period. These files are moved to the temp folder on your Desktop.
If you have files without an extension, you will have to find some other common character to latch onto. For instance, if you have one or more files that begin with the letter s, then you could issue a command such as
mv s* ~/Desktop/temp/
and all files that begin with s will be moved. Or, if you had a bunch of files that had the combination xyz buried in their names, you could issue the command
mv xyz ~/Desktop/temp/
and they would be moved. So, the point of using the wildcard is to find some common characters in the names of a bunch of files, so that you can move them all at once.
The hidden files that Kurt mentioned all begin with a . (period) and you will normally not see those. They are considered invisible files. If you issued the mv * command as I suggested, you will move those also. Kurt's suggestion, which I agree with, is to avoid moving those files, because some of them may have have a special use for the operating system.
I hope this helps. If you have more questions, fire away.
EMAC G4 1.0 GHz Mac OS X (10.4.3) -
Reboot loop: Help me delete all login items with Terminal
I updated my Macbook (5,1) from Lion to Mountain Lion and began soon thereafter to get the error that the computer had restarted after a problem. For a few days the computer would nevertheless reach desktop after a restart and could be used.
I thought that perhaps the error came from the login items and saw on Rogue Amoeba's site that SoundSource isn't yet compatible with ML. Removing it seemed to cure the problem.
But as of this morning the computer is stuck in a restart "loop". It shows the apple and spinner and a grey progress bar. When the bar is almost completed (a millimeter or so remaining) the computer restarts and does the same thing all over.
I have now managed to get to the recovery partition with cmd-r. I have repaired the disk with DU and I would like to remove all login items using Terminal but haven't got a clue how to do it. I have searched but don't find good walkthroughs. So I would very much appreciate help on how to do this.
My login items are Skype, Dropbox and iTeleport.
Cheers and many thanks
/pThanks for the replies.
@ mende1 - I did hold cmd-R to reach the recovery partition. How do I now leave safe mode (if it is stuck in that) and boot normally?
@ Thomas - DU seems to be successful in repairing the disk. It doesn't report any errors - just says what it is "checking", "updating" and "adjusting" (not a very long list at all) - but it concludes with partition map appears to be OK.
My other Mac has all my files so I don't mind reinstalling on this one, except for the fact that I would have to reinstall all the applications and I don't have them with me where I am at the moment.
If I choose to reinstall when booted with cmd-r will it re-download or install from a local copy? Re-downloading will take forever because I only have mobile (3G) broadband here.
Do I have any other options?
Thanks for helping.
/p -
Deleting all workflow items from SAP inbox
hi ,
I'm doing some Workflow testing and I've got a bunch of work items in my
Inbox. Is there a utility I can run that will just delete all of the work
items in my Inbox, regardless of the status?
any suggestions????
thanks in advance for your kind attention.
AshishSo if I don't want a user to receive a particular Workflow message everyday, how can I cancel that? Can someone tell the transaction code and procedure to do this?
Thanks
> Ashish,
>
> In Dev & Test environments you can delete work items
> using txns SWWL or SWWL_TOPLEVEL (Menu Path: Tools ->
> Business Workflow -> Development -> Administration ->
> Workflow Runtime -> Reorganization). However it is
> not recommended to do this in Production. You cancel
> the Workflow in Production
>
> Cheers,
> Ramki Maley.
>
> Please reward points if the answer is helpful.
> For info on awarding points click on this link:
> https://www.sdn.sap.com/sdn/index.sdn?page=crp_help.ht -
I activated my iPhone at the Apple Store and unfortunatley got all the calendar items that were on the computer which obviously aren't mine and I do not want. How do I delete ALL the calendar items so I can start fresh. I do not want to reset because I already manually put in all my phone numbers from my other phone. Thanks for your help.
Hobbers,
All you would have to do is select the calendars that you want to sync from your computer. Under the Info tab in iTunes just select to sync your calendar and at the bottom of the same page in advance options select to replace the information. -
Command-Line question. Delete all but particular folders
Hello. I need to create a batch file that will delete all folders within the "Users" folder except for the Administrator and Administrator.domainname.
Can anyone help?
ThanksYou could try something along the lines of
FOR /F "tokens=*" %%G IN ('DIR /B /A:D c:\test') DO if not "%%G" == "test2" if not "%%G" == "test3" rd /s /q "c:\test\%%G"
but if you do, you may also delete
c:\Users\Public
c:\Users\Default (a hidden folder)
c:\Users\All Users (a system folder)
c:\Users\Default User (a system folder)
Which may be regrettable. If you want an example of what happens then, try reading
http://superuser.com/questions/219082/accidentally-deleted-user-profiles-on-windows-7-cant-log-on-with-other-users
Maybe you are looking for
-
Application Translation Not Working - Primary Key Error
I had created an application translation to Spanish but it wasn't displaying my Spanish translation. I was going to try and redo it so I tried creating a new mapping and then seeding the translatable text. I got a primary key error "ORA-20001: Seed i
-
Help! My Mouse pad is not working properly. The arrow cannot be controlled, it just keeps jumping all over the page. How can I stop this?
-
Script for user setup in Discoverer
Do anyone have a script that I can use to scan a table or spreadsheet with User names and Business areas and setup the users in Discoverer. I need to setup lot of users in Discoverer and manually doing them is a time taking process. Thanks in advance
-
I have a pdf doc that I have email buttons attached to button when I go to upload it to forms central so I can add a submit button to it it enables my email buttons.
-
i sent my iphone in for service but got it back since find my iphone was activated. now it says that the phone is lost and i cant activate it. when i try to follow the instructions on the screen it just says that it can reach the activation servers a