Restore list by name from recyclebin via powershell

Restore list by name from recyclebin via powershell

##############################################

# $url : The site url                                                             #

#$name : The list name                                                     #

#Example : RestoreListByName "http://localhost" "list1"  #

##############################################

#  Import the Microsoft.SharePoint.PowerShell

if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}

function RestoreListByName($url, $name)
{
    
    $spWeb = Get-SPWeb -identity $url
    $spList  = $spWeb.RecycleBin |?{$_.Title -match $name}
    $spWeb.RecycleBin.Restore($spList.Id)
}


 

 

你可能感兴趣的:(Restore list by name from recyclebin via powershell)