{"id":6255,"date":"2020-08-31T13:16:17","date_gmt":"2020-08-31T13:16:17","guid":{"rendered":"https:\/\/www.softreetechnology.com\/?p=6255"},"modified":"2020-08-31T13:16:17","modified_gmt":"2020-08-31T13:16:17","slug":"retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/","title":{"rendered":"Retrieve Recycle Bin Items Using Different Filters Condition &#038; Restore Them Using PNP PowerShell"},"content":{"rendered":"\n<p>In this blog, we will learn how to get number of items present in recycle bin and apply different filter conditions on it. We will also see how to restore the items to its previous location.<\/p>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Steps<\/span>:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong><span style=\"text-decoration: underline;\">First we need to connect site. We can do this following below command<\/span><\/strong><\/li><\/ol>\n\n\n\n<p>Open SharePoint Online Management Shell as administrator and add<br> <strong>  Connect- PnPOnline &#8211; Url $siteURL <\/strong>                                                                                                                                                                                                                       #Executing this line will ask for credentials. Provide use name and password to connect. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/1-3.png\" alt=\"\" class=\"wp-image-6256\" width=\"290\" height=\"233\"\/><\/figure><\/div>\n\n\n\n<p>2. <strong><span style=\"text-decoration: underline;\">To get all items count present in recyclebin use below commands<\/span><\/strong><\/p>\n\n\n\n<p><strong>(Get-PnPRecycleBinItem).count<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/2-3-1024x86.png\" alt=\"\" class=\"wp-image-6257\" width=\"857\" height=\"72\"\/><\/figure><\/div>\n\n\n\n<p>3. <strong><span style=\"text-decoration: underline;\">To apply different filter conditions, follow below commands<\/span><\/strong><\/p>\n\n\n\n<p>A.<span style=\"text-decoration: underline;\"> <\/span><strong><span style=\"text-decoration: underline;\">Retrieve items from recycle bin applying filter conditions on Users<\/span><\/strong><\/p>\n\n\n\n<p>We will apply filter on the user\nwho deleted the items added it to the first-stage recycle bin through user\nemail address.<\/p>\n\n\n\n<p>              <strong>Get-PnPRecycleBinItem- FirstStage | ?DeletedByEmail -eq &#8216;user@domain.com&#8217;<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/3-3-1024x581.png\" alt=\"\" class=\"wp-image-6258\" width=\"677\" height=\"384\"\/><\/figure><\/div>\n\n\n\n<p>B. <strong><span style=\"text-decoration: underline;\">Retrieve items from recyclebin applying filter conditions on file extensions<\/span><\/strong><\/p>\n\n\n\n<p>      <strong>Get-PnPRecycleBinItem -FirstStage | ? LeafName -like &#8216;*.docx&#8217;<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/4-3-1024x228.png\" alt=\"\" class=\"wp-image-6259\" width=\"719\" height=\"160\"\/><\/figure><\/div>\n\n\n\n<p>C. <strong><span style=\"text-decoration: underline;\">Retrieve items from recyclebin applying filter conditions on item title<\/span><\/strong><\/p>\n\n\n\n<p>       <strong>Get-PnPRecycleBinItem | ? Title -Like &#8216;*DemoBook*&#8217; | ft<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/5-2-1024x118.png\" alt=\"\" class=\"wp-image-6260\" width=\"894\" height=\"103\"\/><\/figure><\/div>\n\n\n\n<p>4. <strong><span style=\"text-decoration: underline;\">Apply restore to items retrieved through filter conditions items title contain<\/span><\/strong><\/p>\n\n\n\n<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Get-PnPRecycleBinItem -firststage\n| ? {($_.DeletedDate -gt $restoreDate) -and ($_.Title&nbsp; -Like &#8216;*DemoBook*&#8217;)} |\nRestore-PnpRecycleBinItem -Force<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/6-1-1024x55.png\" alt=\"\" class=\"wp-image-6261\"\/><\/figure><\/div>\n\n\n\n<p style=\"text-align:center\"><strong>Img 1. Applying restore command<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/7-1-1024x363.png\" alt=\"\" class=\"wp-image-6262\" width=\"697\" height=\"247\"\/><\/figure><\/div>\n\n\n\n<p style=\"text-align:center\"><strong>Img 2. Before applying restore command<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/8-1-1024x389.png\" alt=\"\" class=\"wp-image-6263\" width=\"716\" height=\"272\"\/><\/figure><\/div>\n\n\n\n<p style=\"text-align:center\"><strong>Img 3. After apply restore command <\/strong><\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong><em>Keywords<\/em><\/strong><\/span>:<br> \u2022 Retrieve recycle bin items using filter condition on user who deleted items.<br> \u2022 Retrieve recycle bin items using filter conditions on items having extension match.<br> \u2022 Retrieve recycle bin items using filter condition on items title matched.<br> \u2022 Restore items from first stage recycle bin using PNP PowerShell.<br> \u2022 Get no of items stored in recycle bin using PNP PowerShell.<br> \u2022 Restore items from recycle bin using PNP PowerShell.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we will learn how to get number of items present in recycle bin and apply different filter conditions on it. We will also see how to restore the items to its previous location. Steps: First we need to connect site. We can do this following below command Open SharePoint Online Management Shell as administrator and add Connect- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[298],"tags":[],"class_list":["post-6255","post","type-post","status-publish","format-standard","hentry","category-pnp-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Retrieve Recycle Bin Items Using Different Filters Condition &amp; Restore Them Using PNP PowerShell - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Retrieve Recycle Bin Items Using Different Filters Condition &amp; Restore Them Using PNP PowerShell - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"In this blog, we will learn how to get number of items present in recycle bin and apply different filter conditions on it. We will also see how to restore the items to its previous location. Steps: First we need to connect site. We can do this following below command Open SharePoint Online Management Shell as administrator and add Connect- [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-31T13:16:17+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Retrieve Recycle Bin Items Using Different Filters Condition & Restore Them Using PNP PowerShell - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Retrieve Recycle Bin Items Using Different Filters Condition & Restore Them Using PNP PowerShell - Softree Technology","og_description":"In this blog, we will learn how to get number of items present in recycle bin and apply different filter conditions on it. We will also see how to restore the items to its previous location. Steps: First we need to connect site. We can do this following below command Open SharePoint Online Management Shell as administrator and add Connect- [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/","og_site_name":"Softree Technology","article_published_time":"2020-08-31T13:16:17+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Retrieve Recycle Bin Items Using Different Filters Condition &#038; Restore Them Using PNP PowerShell","datePublished":"2020-08-31T13:16:17+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/"},"wordCount":305,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/1-3.png","articleSection":["PnP PowerShell"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/","url":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/","name":"Retrieve Recycle Bin Items Using Different Filters Condition & Restore Them Using PNP PowerShell - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/1-3.png","datePublished":"2020-08-31T13:16:17+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#primaryimage","url":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/1-3.png","contentUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/08\/1-3.png"},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/retrieve-recycle-bin-items-using-different-filters-condition-restore-them-using-pnp-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Retrieve Recycle Bin Items Using Different Filters Condition &#038; Restore Them Using PNP PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=6255"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6255\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=6255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=6255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=6255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}