First of all sorry if this is an obvious question, I searched a lot but can't find the solution.
When I open an spsite
in powershell like this:
$spsite = Get-SPSite "https://adress"
And then I try to get all the webs like so
$spsite.allwebs
I get the following error:
$spsite.allwebs : Exception has been thrown by the target of an invocation
+ CategoryInfo : NotSpecified: (:) [], TargetInvocationExcept
+ FullyQualifiedErrorId : System.Reflection.TargetInvocationException
I don't understand what I am doing wrong, on my other SP server this works fine.
Thanks in advance,
Edit To be more clear about my problem I will post 2 screenshots
Here you can see that I am logged in as sp_admin
and I am primary admin in the site collection.
Here you see the commands I execute and the error I get.
Edit 2
$spsite.gettype
output:
PS C:\Users\sp_admin> $spsite.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False SPSite System.Object
$spsite = Get-SPSite "https://address"
, right?