11

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!!

5 Answers 5

7

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

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

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
  • 1
    excellent new idea
    – Rany
    Commented Apr 21, 2017 at 13:05
2
Get-PNPSite | where-Object {$_["Url"] -eq "http://rany1/xxx"}
3
2

Small correction in your syntax.

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

https://technet.microsoft.com/en-us/library/ee177028.aspx?f=255&MSPPError=-2147217396

1
  • excellent repeated answer :)
    – Rany
    Commented Apr 21, 2017 at 13:06
1

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 and acknowledge you have read our privacy policy.

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