Forum Discussion
Get-DistributionGroup error
【I have a Exchange Online Hierarchical books below:】
Group1
╚Group2
╚Group3
╚Group4
【The group all create by powershell script below and work fine till today】
$objectDistriGroup = $null
$objectDistriGroup = Get-DistributionGroup - Identity $stringAlias 2>&1
#Check Alias
If($objectDistriGroup -eq $null){
$objectDistriGroup = Get-DistributionGroup - Identity $stringName 2>&1
#Check Name
If($objectDistriGroup -eq $null){
$objectDistriGroup = New-DistributionGroup -Name $stringName -Alias $stringAlias -Confirm:$false 2>&1
$objectDistriGroup | Set-Group -IsHierarchicalGroup $true - SeniorityIndex $stringSeniorityIndex
#Add to parent group
Add-DistributionGroupMember - Identity $stringParent -Member $stringAlias -Confirm:$false 2>&1
}
}
)
【Today I'm trying to add "Group5" in "Group1", but got the output below in my log file】
PS>error(Invoke-WebRequest): "{"error":{"code":"NotFound","message":"Error executing cmdlet","details":{"code":"Context","target":"","message":"{¥"ClassName¥":¥"Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException¥",¥"Message¥":¥"....................................The operation couldn't be performed because object '{0}' couldn't be found on '{1}'...................................."internalexception":{"message":"Exception of type 'Microsoft.Exchange.Management.PSDirectInvoke.DirectInvokeCmdletExecutionException' was thrown."
【After some test, looks like "Get-DistributionGroup" cause these error message.】
But when I use cmdlet "Get-DistributionGroup - Identity Group5"
It return "Group5" information as normal.
DId I missed something update?
How to fix this error.
Thank you so much, Any information will be appreciated!
12 Replies
- WheelnamesOccasional Reader
Hey Jason, your issue with `Get-DistributionGroup` reminds me of how crucial it is to ensure the right parameters are set for script efficiency, especially in hierarchical setups like yours. While troubleshooting these processes, I found that tools like https://wheelnames.org/ can surprisingly aid in managing name-based tasks efficiently. Have you tried running a diagnostic to see if there's an alias conflict?
- AbdulWaheed3Tin Contributor
I’d first check whether the problem is related to how the script is resolving the group rather than the group actually being missing. Since Get-DistributionGroup -Identity Group5 works manually, that suggests the object itself exists and Exchange Online can resolve it.
One thing I’d test is capturing the exact value being passed through $stringAlias and $stringName immediately before Get-DistributionGroup. Hidden whitespace, an unexpected value, or a difference between the alias and display name could cause the scripted lookup to behave differently.
I’d also test the lookup with an explicit result variable and $ErrorActionPreference = 'Stop' so the script isn't treating an error object from 2>&1 as a normal result. That can make $objectDistriGroup -eq $null behave unexpectedly because the command's error output may be captured in the variable.
For example, separating the lookup from error handling should make it easier to determine whether the failure is actually the Get-DistributionGroup lookup or the subsequent Add-DistributionGroupMember operation.
- LearnTodayCopper Contributor
(Check full identity): "Have you tried using the full identity path for Group5? Sometimes using the full Distinguished Name or email instead of just the alias helps resolve this error.
- blanktextCopper Contributor
It's so frustrating when a script that's been working fine suddenly breaks. I've had that happen before, and it turned out to be an invisible character in my variable. Maybe some https://blank-text.org got copied into your string by mistake?
- chrismartin49Copper Contributor
I’ve seen similar PowerShell issues in Exchange where invisible or non-printing characters cause command failures. It’s often due to copying text from formatted sources. I shared more on this topic at https://espaciosblanco.com/
- csdewaCopper Contributor
Use try/catch instead of 2>&1 to avoid losing object references.
Add Start-Sleep to account for replication delay.
Confirm you're using correct identity values (alias vs email vs https://adammag.co.uk/best-online-casinos-in-malaysia/).
If issue persists, open a support ticket with Microsoft including full logs and timestamps. - danishseo036Copper Contributor
It seems you're encountering a Get-DistributionGroup error while trying to add "Group5" to "Group1." Double-check the identities of $stringParent, $stringAlias, and $stringName to ensure they’re correct. Also, verify your permissions and consider waiting a few minutes for changes to propagate. If issues persist, you may need to update your PowerShell module or consult Microsoft support, similar to how https://multipackinternational.com/product-category/aluminium-products/foils/ manage their production processes for efficiency.
- danishseo036Copper Contributor
Have you tried using the full file path for your project within Text , like selecting "Project1/Clip5" instead of just "Clip5"? It might help resolve the media not found error. Double-checking the https://thecapcut.live/ structure and ensuring all media dependencies are intact could also be beneficial. Good luck troubleshooting!
- arslan795Copper ContributorIt seems you’re encountering a "NotFound" error when trying to add "Group5" to "Group1," despite being able to retrieve "Group5" using Get-DistributionGroup. This may indicate an issue with how the script handles the $stringParent variable, which should refer to "Group1." Ensure that $stringParent is set correctly and that "Group1" exists. Additionally, check for any recent updates or changes in permissions that might affect group operations. If the issue persists, consider running the script with detailed logging or error handling to capture more context about the failure.
https://ggsaloncorvallis.com/hair_salon/ - afzalyunasCopper Contributor
The "Get-DistributionGroup" error in Exchange Server often occurs when there is a misconfiguration in the permissions or when the Exchange Management Shell cannot retrieve the distribution group information. Common causes include insufficient user rights, corrupted Active Directory objects, or outdated PowerShell modules. To resolve this issue, ensure proper permissions, verify the group’s existence in Active Directory, and update your Exchange Management Shell. Regular maintenance and careful management of permissions can prevent such errors. https://urdusehat.com/
- jhoncarles725Copper Contributor
Have you tried using the full identity path for "Group5" within your script, like "Get-DistributionGroup -Identity Group1/Group5"? It might help resolve the object not found error. Double-checking the https://invisibletext.net/ hierarchical structure and ensuring all dependencies are in place could also be beneficial. Good luck troubleshooting.
- greenhomeplanCopper ContributorSometimes, simply restarting your PowerShell session or reconnecting to your Exchange server can resolve temporary issues.
If these steps don’t resolve the issue, consult the Microsoft documentation or reach out to Microsoft Support for further assistance.