Yass
Yass

Reputation: 602

Sharepoint powershell IF condition

i have a simple if condition as follows...

$site = new-object Microsoft.SharePoint.SPSite($url)
$sitelists =  foreach ($web in $site.AllWebs) 
{
    if ($web -eq "Search")
    {
      Write-Host "Come in"  
    }
}

though the site list returns value "Search" the if condition always fails.

Any thoughts?

Upvotes: 0

Views: 3738

Answers (1)

Shay Levy
Shay Levy

Reputation: 126842

I can't test this now but I think you need to compare the Name property?

if ($web.Name -eq "Search")

Upvotes: 1

Related Questions