Get-DistributionGroup error

Copper Contributor

【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!

4 Replies

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 Invisible Text hierarchical structure and ensuring all dependencies are in place could also be beneficial. Good luck troubleshooting.

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. Uses in Urdu

Sometimes, 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.
It 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/