Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Restore-PnPRecycleBinItem - Type Conversion Errors #4664

Open
1 of 6 tasks
YuriySamorodov opened this issue Jan 6, 2025 · 1 comment · May be fixed by #4667
Open
1 of 6 tasks

[BUG] Restore-PnPRecycleBinItem - Type Conversion Errors #4664

YuriySamorodov opened this issue Jan 6, 2025 · 1 comment · May be fixed by #4667
Assignees
Labels
bug Something isn't working

Comments

@YuriySamorodov
Copy link
Contributor

Reporting an Issue or Missing Feature

I'm reporting an issue with the Restore-PnPRecycleBinItem cmdlet which appears to have a type conversion problem that makes it impossible to restore items from the recycle bin.

Expected behavior

When using Restore-PnPRecycleBinItem with an Identity parameter (either directly or piped from Get-PnPRecycleBinItem), the cmdlet should successfully restore the item to its original location as shown in the help examples.

Actual behavior

The cmdlet fails with type conversion errors regardless of how the Identity is provided:
CleanShot 2025-01-06 at 16 05 27

  1. When using direct ID:
Restore-PnPRecycleBinItem -Identity $torestore.Id
Restore-PnPRecycleBinItem: Cannot bind parameter 'Identity'. Cannot convert the "12617497-069e-4fe3-a032-39b5f3956406" value of type "System.Guid" to type "PnP.PowerShell.Commands.Base.PipeBind.RecycleBinItemPipeBind".
  1. When piping from Get-PnPRecycleBinItem:
Get-PnPRecycleBinItem -Identity $torestore.Id | Restore-PnPRecycleBinItem
Get-PnPRecycleBinItem: Cannot bind parameter 'Identity'. Cannot convert the "Microsoft.SharePoint.Client.RecycleBinItem" value of type "Microsoft.SharePoint.Client.RecycleBinItem" to type "System.Guid".
  1. Even when trying to pipe the entire command:
Restore-PnPRecycleBinItem -Identity ( Get-PnPRecycleBinItem -Identity $torestore.Id )
Restore-PnPRecycleBinItem: Object reference not set to an instance of an object.

Steps to reproduce behavior

  1. Connect to a SharePoint site using Connect-PnPSite
  2. Get a recycle bin item using Get-PnPRecycleBinItem
  3. Try to restore it using any of the following methods:
$item = Get-PnPRecycleBinItem
Restore-PnPRecycleBinItem -Identity $item.Id
# or
$item | Restore-PnPRecycleBinItem
# or
Restore-PnPRecycleBinItem -Identity $item

What is the version of the Cmdlet module you are running?

Please include the output of Get-Module -Name "PnP.PowerShell" -ListAvailable

PnP.PowerShell 2.99.96

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Based on the command prompt shown in the screenshots, this is being run on Windows.

@YuriySamorodov YuriySamorodov added the bug Something isn't working label Jan 6, 2025
@jackpoz jackpoz linked a pull request Jan 7, 2025 that will close this issue
3 tasks
@jackpoz
Copy link
Contributor

jackpoz commented Jan 7, 2025

I created a PR at #4667 that solves the exceptions mentioned in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants