I want to loop over all web application's site collection and activate a feature on root web except the root site collection. How to know if current site collection is the root one.

PS : I've used to compare site collection url with web application url but this isn't the best practice for me.

if($site.Url -like $WebAppUrl)

I don't have the code. But, Go for something like $site.WebApplication.Sites[0].Url . Basically, the root site collection is the first item in 'Sites' collection.

Hope its clear :)

  • Yeah it's clear thanks. I already thought about this option, but I don't love indexed properties. I'm looking for something more generic and with the least risk of change and errors. – KhalilG Mar 5 '15 at 11:22

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.