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

8

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

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

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
2
Get-PNPSite | where-Object {$_["Url"] -eq "http://rany1/xxx"}
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

  • excellent repeated answer :) – Rany Apr 21 '17 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, privacy policy and cookie policy

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