I have site collections list

I want to check if http://Rany1/xxx is exist using where-object instead of foreach if in power shell.

I tried Get-SPsite | where {$_Url -eq "http://Rany1/xxx"} it's not working

Help me please!!


there is small mistake in your code. there should be a "." after '$_". try this

Get-SPsite | where {$_.Url -eq "http://Rany1/xxx"}

And just to add to the list of options, you can also replace Where-Object and where with a little question mark ?.

Get-SPsite | ?{$_.Url -eq "http://Rany1/xxx"}

Reference: Where-Object

  • 1
    excellent new idea – Rany Apr 21 '17 at 13:05
Get-PNPSite | where-Object {$_["Url"] -eq "http://rany1/xxx"}

Small correction in your syntax.

Get-SPSite | Where-Object {$_.Url -eq "<<site url>>"}


  • excellent repeated answer :) – Rany Apr 21 '17 at 13:06

The below format also we can use

Get-PNPSite | where-Object {$_["Name"] -eq "Site name"}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.