• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 639
  • Last Modified:

powershell

I have Active Directory with the schema extended for Exchange 2013.  I am looking to run a powershell 3.0 script (from my Windows 7 x64 laptop) that will provide me with a report/list of all configured ManagedBy (schema attribute) distribution groups within my Active Directory.  I can view the ManagedBy attribute as a property of the Distribution Group, but I do not have the get-distributiongroup cmdlet on my powershell.  Ideally I'd like to run something similar to below...

"Get-DistributionGroup * | Format-Table Name, ManagedBy"

Do you know of a module I can import to get that cmdlet?  I have the below two PS lines but they need to be joined and search entire directory (if that makes sense).


#This will get me a list of all global distribution groups, displaying only the group name sorting by the name.
"Get-ADGroup -Filter {GroupCategory -eq "Distribution" -and GroupScope -eq "Global"} | Sort-Object | Format-Table Name"

#This will display a specific group and the managedby property.
"Get-ADGroup -Identity <groupname> -Properties ManagedBy"

Thoughts?
0
jmachado81
Asked:
jmachado81
1 Solution
 
Brad GrouxSenior Manager (Wintel Engineering)Commented:
I believe for security reasons Exchange related PowerShell Cmdlets must be run from the Exchange Management Shell.

http://technet.microsoft.com/en-us/library/dd638134(v=exchg.150).aspx

Exchange Management Tools which were utilized in previous versions of Exchange have been replaced by the Exchange Admin Center in Exchange 2013. EAC is now web based and can be accessed via IE at https://<CASServerName>/ecp  internally or https://mail.contoso.com/ecp externally.

http://technet.microsoft.com/en-us/library/jj150562%28v=exchg.150%29.aspx
0
 
jmachado81Author Commented:
Our Exchange environment is hosted in Office365, but that is synced to our AD.  Since Office365 pulls from our AD we should "theoretically" be able to run a script against our internal AD to get that information.

With that additional information, would we have to do a "connect-msolservice" then?  Again I can see all these settings when I open ADUC.
0
 
Adam FarageEnterprise ArchCommented:
To connect to Office 365 for Exchange using PowerShell, you would need to import a new session into the powershell module: http://technet.microsoft.com/en-us/library/jj984289%28v=exchg.150%29.aspx

You *could* use the Exchange 2013 Exchange Management Shell for this, but you would still have to import a new session. I usually manage my clients O365 from my desktop, since Windows 8.1 comes with PowerShell.

I think that is where your issue is.

The same thing goes if you are doing DirSync to Azure AD: http://technet.microsoft.com/en-us/library/jj151815.aspx
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
footechCommented:
Get-ADGroup -Filter {GroupCategory -eq "Distribution" -and GroupScope -eq "Global"}  -Properties ManagedBy | Sort-Object Name | Format-Table Name, ManagedBy

Open in new window

This combines the two and displays the Name and ManagedBy info.  Since this information is available in your AD, you don't have to connect to Office365 to get it.
0
 
jmachado81Author Commented:
That is great footech.  A colleague was able to manipulate that to this, so it doesn't display ones with a null value.

Get-ADGroup -Filter {GroupCategory -eq "Distribution" -and GroupScope -eq "Global"} -property * | where-object {$_.managedby.length -gt 0}| select name,managedby |Sort-Object -Property name
0
 
footechCommented:
If you're concerned at all about the speed with which that runs, change -property * to -property ManagedBy for the Get-ADGroup command.  If you don't have that large a number of groups you may not see a noticeable difference however.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now