I am in the beginning stages of testing our bulk distribution group, contact and mailbox creations scripts for o365. In testing the script I am using for creating distribution groups, I received an error that the -emailaddresspolicyenabled $true couldn’t be found as a parameter. Everything I have looked at shows it being used with the set-distribution group command. Any assistance would be greatly appreciated.
$credential = Get-Credential
Import-Module MsOnline
Connect-MsolService -Credential $credential
$exchange365 = New-PSSession -ConfigurationName Microsoft.exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $exchange365 -DisableNameChecking
$distrogroup = Import-csv c:\temp\o365group.csv
$filename = "c:\temp\members.csv"
foreach ($i in $distrogroup)
{
new-distributiongroup -Name $i.Name -Alias $i.Alias -primarysmtpaddress $i.Smtp -OrganizationalUnit $i.OrganizationalUnit -ManagedBy $i.manager
}
sleep 120
foreach($i in $distrogroup)
{
$groupname = $i.name
set-distributiongroup $groupname -RequireSenderAuthenticationEnabled $FALSE -EmailAddressPolicyEnabled $true
}
sleep 240
if(Test-Path $filename)
{
$members = Import-csv c:\exchangetools\members.csv
foreach ($i in $members)
{add-distributiongroupmember $i.groupname -Member $i.Name }