public/Get-RBACComponentEndpoints.ps1
Function get-RBACComponentEndpoints { [CmdletBinding(DefaultParameterSetName='None')] Param ( [Parameter(Mandatory=$False, Position = 0, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)] [Parameter(ParameterSetName = 'SpecificComponent', Mandatory=$True, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)] [ValidateScript({ [bool](get-rbacOrg -org $_) })] [ArgumentCompleter( {(get-rbacOrg).Org})] [String[]]$Org, [Parameter(ParameterSetName = 'SpecificComponent', Mandatory=$False, Position = 1, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)] [ArgumentCompleter( {(get-rbacComponent).Component})] [String[]]$Component ) Process{ if ($PsItem.org) { $Org = $_.Org} if ($PsItem.Component) {$Component = $_.Component} if ($Org) { $OrgList = get-rbacOrg -org $org } else { $OrgList = get-rbacOrg } foreach ($orgObject in $orgList) { if ($component) { $ComponentList = get-RBACComponent -org $orgObject.org -component $Component } else { $ComponentList = get-RBACComponent -org $orgObject.org } foreach ($componentObject in $componentList) { $ComponentPath = $ComponentObject.distinguishedName $EndpointPath = "OU=Endpoints,$ComponentPath" Get-ADComputer -SearchBase $EndpointPath -Filter * -properties OperatingSystem,OperatingSystemVersion| select-Object @{n="Endpoint";e={$_.name}},@{n="Component";e={$Component}},@{n="Org";e={$Org}},OperatingSystem,OperatingSystemVersion,DistinguishedName } } } } |