Following is a powershell function to check for a existence of folder in a document library.
Function CheckFolder($listParm) { TRY { $ErrActionPref = "CONTINUE"; $spQry = New-Object Microsoft.SharePoint.SPQuery $camlQry = "<Where> <And> <Contains> <FieldRef Name='ContentType' /> <Value Type='Computed'>Folder</Value> </Contains> </And> <And> <Eq> <FieldRef Name='Title' /> <Value Type='Text'>Name of Folder-To-Check</Value> </Eq> </And> </Where>" $spQry.ViewAttributes = "Scope = 'Recursive'" $spQry.Query = $camlQry $spLstItms = $listParm.GetItems($spQry) if ($spLstItms.Items.Count -gt 0)
{
foreach ($item in $spLstItms) { #items found return $true }
} } CATCH { #Error handling return $false } return $false } #I am calling this CheckFolder function as follows if ((CheckFolder $list) -eq $true) { #Matching folder found }
When I run the checkFolder function, it is not finding the folder within the document library.
Any ideas on why it is not working.
Thanks
Nate