#PowerShell HowTo get the property of the object from the previous pipe level

[System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
function Get-SPSite{
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$farm.services | % {if($_.WebApplications.Count){$_.WebApplications}} | % {if($_.sites.Count){$_.sites}}
}

function Get-SPUser { process {
$_ | Add-Member -memberType NoteProperty -name “Site” -value $Site.Url
$_ | Add-Member -memberType NoteProperty -name “Title” -value $Site.RootWeb.Title
$_ | Add-Member -memberType NoteProperty -name “Group” -value $Group.Name
$_
}
}
Get-SPSite | % {$Site = $_;$_.RootWeb.Groups} | ? {$_.Name -match “^.*Owners” } | % {$Group = $_;$_.Users} | Get-SPUser | select Site, Title, Group, Name, Email, Id

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s