When I try to run following python PowerShell command:
p1 = subprocess.run(
['powershell',
'-Command',
'Add-DistributionGroupMember -identity "Staff" -member "eng.hassan"'],
capture_output=True)
I got following error:
'Add-DistributionGroupMember' is not recognized as an internal or external command, operable program or batch file.
Other PowerShell commands executed successfully like (Get-ADUser), I think the error cause this command is part of Exchange Online module not the Active Directory commands.