I need some help to modify the below script to show additional column Office 365 or OnPremise:
Code: Select all
Get-ADGroup -Filter {Name -like '*IT*'} | Select-Object @{ n='Group'; e={ $_.Name } }, @{ n='Members'; e={ (Get-ADGroup $_.DistinguishedName -Properties Members | Select-Object Members).Members } } |
Get-ADGroupMember -Recursive |
Get-ADUser -Properties Mail | Select-Object Name, sAMAccountName, Mail |
Export-CSV -path "C:\RESULT\Group_members.csv" -NoTypeInformation
I also have tried the below script to query OnPremise AD with the specific attributes, but still failed no result returned?
Code: Select all
Get-ADUser -Filter * -Properties msExchRemoteRecipientType, msExchRecipientDisplayType, msExchRecipientTypeDetails, targetAddress |
Where-Object {($_.msExchRemoteRecipientType -eq 4) -and
($_.msExchRecipientDisplayType = '-2147483642') -and
($_.msExchRecipientTypeDetails = '2147483648') -and
($_.targetAddress -contains "*.onmicrosoft.com*")
}
But it returns some error:
Any help would be greatly appreciated.msExchRecipientDisplayType : The term 'msExchRecipientDisplayType' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:3 char:10
+ (msExchRecipientDisplayType = '-2147483642') -and
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (msExchRecipientDisplayType:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Thanks,