bwya77 / O365-Admin-Center

The O365 Admin Center is a GUI application that administrators can use to administer every aspect of Office 365 including Exchange Online, Compliance Center, SharePoint and Skype for Business.
Other
300 stars 69 forks source link

postmaster script to include #13

Open IIIdefconIII opened 5 years ago

IIIdefconIII commented 5 years ago

// Set Variables \

$klantdomein = $name = Read-Host 'What is the domain name? (exaxmple. systrax.nl)' $postmasterdomain = "postmaster@$name" $postmasteralias1 = "abuse@$name" $postmasteralias2 = "sysadmin@$name" $postmasteralias3 = "hostmaster@$name" $postmasteralias4 = "webmaster@$name" $ExternalContactsFile = "D:\CloudStation\Operations\Technical Notes\Scripts\Office365\Office365 postmaster script\ExternalContacts.csv"

// Connect to O365 Tenant account \

$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session

// Import of comma separated file \

Import-Csv $ExternalContactsFile |%{New-MailContact -Name $.Name -DisplayName $.Name -ExternalEmailAddress $.ExternalEmailAddress -FirstName $.FirstName -LastName $_.LastName}

// Second import for extra values \

$contacts = Import-CSV $ExternalContactsFile $contacts | ForEach {Set-Contact $.Name -StreetAddress $.StreetAddress -City $.City -StateorProvince $.StateorProvince -PostalCode $.PostalCode -Phone $.Phone -MobilePhone $.MobilePhone -Pager $.Pager -HomePhone $.HomePhone -Company $.Company -Title $.Title -OtherTelephone $.OtherTelephone -Department $.Department -Fax $.Fax -Initials $.Initials -Notes $.Notes -Office $.Office -Manager $.Manager}

// Hide mail adress from Global Adress Book \

Set-MailContact "Systrax Operations" -HiddenFromAddressListsEnabled $true

//Create distribution groep and add members \

New-DistributionGroup -Name "Postmaster $name" -Alias Postmaster$name Add-DistributionGroupMember -Identity "Postmaster$name" -Member "Systrax Operations" Set-DistributionGroup postmaster$name -emailaddresses postmaster@$name Set-DistributionGroup postmaster$name -emailaddresses @{Add=$postmasteralias1,$postmasteralias2,$postmasteralias3,$postmasteralias4} Set-DistributionGroup postmaster$name -RequireSenderAuthenticationEnabled $False

// Pause for 6 seconds so O365 can create the postmaster account \

Start-Sleep -s 10

// Set send emails from outside \

Get-DistributionGroup -identity Postmaster* | Set-DistributionGroup -RequireSenderAuthenticationEnabled $False

// Kill Session \

Remove-PSSession $Session