[System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = Get-SPSite "http://arwqa.grouphc.net/"
$web = $site.rootweb
$list = $web.Lists["ARWTicket"]
$caml=""
#optional filter
#<Where><Eq><FieldRef Name=""ContentType"" /><Value Type=""Text"">Form</Value></Eq></Where>"
$query=new-object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'"
$query.Query=$caml
$items=$list.GetItems($query)
Write-Host $items.Count
$count = $items.Count - 1
foreach ($item in $list.Items)
{
write-host "`rProcessing ID: $($item.ID) ($i of $batchSize)" -nonewline
$listItem =$items.GetItemById($item.ID) #1187
try
{
$IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($listItem)
if ($IsRecord -eq $true)
{
[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::UndeclareItemAsRecord($listItem)
Write-Host "Success:Undeclared $($listItem.Title)"
}
}
Catch [system.exception]
{
Write-Host "Error:Item $($listItem.Title)"
}
$listItem.Delete();
}
#$items | % { $list.GetItemById($_.Id).Delete() }
#DEleting folders
$query = New-Object Microsoft.SharePoint.SPQuery
$camlQuery = '<Where><Eq><FieldRef Name="ContentType" /><Value Type="Text">Folder</Value></Eq></Where>'
$query.Query = $camlQuery
$items = $list.GetItems($query)
Write-Host("DELETED FILE: " + $count)
for ($intIndex = $items.Count - 1; $intIndex -gt -1; $intIndex--)
{
$items.Delete($intIndex);
Write-Host("DELETED FILE: " + $intIndex)
}
$web.Dispose()
$site.Dispose()
$site = Get-SPSite "http://arwqa.grouphc.net/"
$web = $site.rootweb
$list = $web.Lists["ARWTicket"]
$caml=""
#optional filter
#<Where><Eq><FieldRef Name=""ContentType"" /><Value Type=""Text"">Form</Value></Eq></Where>"
$query=new-object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'"
$query.Query=$caml
$items=$list.GetItems($query)
Write-Host $items.Count
$count = $items.Count - 1
foreach ($item in $list.Items)
{
write-host "`rProcessing ID: $($item.ID) ($i of $batchSize)" -nonewline
$listItem =$items.GetItemById($item.ID) #1187
try
{
$IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($listItem)
if ($IsRecord -eq $true)
{
[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::UndeclareItemAsRecord($listItem)
Write-Host "Success:Undeclared $($listItem.Title)"
}
}
Catch [system.exception]
{
Write-Host "Error:Item $($listItem.Title)"
}
$listItem.Delete();
}
#$items | % { $list.GetItemById($_.Id).Delete() }
#DEleting folders
$query = New-Object Microsoft.SharePoint.SPQuery
$camlQuery = '<Where><Eq><FieldRef Name="ContentType" /><Value Type="Text">Folder</Value></Eq></Where>'
$query.Query = $camlQuery
$items = $list.GetItems($query)
Write-Host("DELETED FILE: " + $count)
for ($intIndex = $items.Count - 1; $intIndex -gt -1; $intIndex--)
{
$items.Delete($intIndex);
Write-Host("DELETED FILE: " + $intIndex)
}
$web.Dispose()
$site.Dispose()
No comments:
Post a Comment