Hi,
How do I get $.name to be working on the script that refer to the same variable.
$_.name only working the first condition checking.
Import-Csv .\DG.csv | ForEach {
if (get-distributiongroup $_.name){
Add-DistributionGroupMember -Identity $_.name -member $_.EmailAddress
}
else{
New-DistributionGroup -Name $._name -OrganizationalUnit "Contoso.com/Groups" -PrimarySmtpAddress $_.PrimarySmtpAddress -Type "Distribution" -MemberDepartRestriction Closed
Add-DistributionGroupMember -Identity $_.name -member $_.EmailAddress
}
}