enter code hereFind my script and the error messages I'm getting on some of get-distribution group attributes.
The attributes are: managedby memberjoinrestriction memberdepartrestriction requiresenderauthenticationenabled
When i exclude the the above attributes, the scripts returns well without error.
Assist me to understand where i'm doing it wrong.
The script: The script is supposed to bulk export information for distribution groups
$Groups = Get-DistributionGroup –ResultSize Unlimited
$Groups | ForEach-Object {
$group = $_.Name
$primarySMTPAddress = $_.PrimarySMTPAddress
$managedby = $._ManagedBy
$memberjoinrestriction = $._MemberJoinRestriction
$memberdepartrestriction = $._MemberDepartRestriction
$requiresenderauthenticationenabled = $._RequireSenderAuthenticationEnabled
Get-DistributionGroupMember $group | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Group = $group
GroupPrimarySMTPAddress = $primarySMTPAddress
Member = $_.Name
ManagedBy = $managedby
MemberJoinRestriction = $memberjoinrestriction
MemberDepartRestriction = $memberdepartrestriction
RequireSenderAuthenticationEnabled = $requiresenderauthenticationenabled
EmailAddress = $_.PrimarySMTPAddress
}}} | Export-CSV "C:\DistributionGroupinfov1.csv" -NoTypeInformation -Encoding UTF8```
The error message is
```$._ManagedBy : The term '$._ManagedBy' 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:5 char:14
+ $managedby = $._ManagedBy
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($._ManagedBy:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
$._MemberJoinRestriction : The term '$._MemberJoinRestriction' 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:6 char:26
+ $memberjoinrestriction = $._MemberJoinRestriction
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($._MemberJoinRestriction:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
$._MemberDepartRestriction : The term '$._MemberDepartRestriction' 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:7 char:28
+ $memberdepartrestriction = $._MemberDepartRestriction
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($._MemberDepartRestriction:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
$._RequireSenderAuthenticationEnabled : The term '$._RequireSenderAuthenticationEnabled' 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:8 char:39
+ ... resenderauthenticationenabled = $._RequireSenderAuthenticationEnabled
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($._RequireSenderAuthenticationEnabled:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException```
When i run the command individually with a single attribute, it returns well without error
```Get-DistributionGroup -identity "support" | Format-table RequireSenderAuthenticationEnabled```