0

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```
Bernke
  • 66
  • 7
  • 1
    It's `$_.` not `$._` :P – T-Me Sep 17 '21 at 11:01
  • Wow! wow! wow!, thank you brother. Have seen it. – Bernke Sep 17 '21 at 11:04
  • Hello sir, Can you help specify specific attributes that accepts multiple values to select the value of what i need, for example, ```-managedby``` attributes accepts either: ```Name, Alias, Distinguished name (DN), Canonical DN, Email address, GUID``` I need to pull the ```email address``` not the ```Name```. – Bernke Sep 17 '21 at 11:16
  • I think that would be good as a question on it's own. Do you mean you want to get the possible values that an enumerator accepts or to create an enumerator on your own? – T-Me Sep 17 '21 at 11:25

0 Answers0