Hi All
I have a really hard script that I need desperate help on. If anyone can help so that I can schedule to run over night, every night? PS my scripting knowledge is as good as a hamster.
I need help creating a powershell script and or VB scripts for Exchange online to automatically add contacts and add them to a mail enabled group (not public folder or tradition distribution list).
Step one
convert a xlsx file in to a csv files (this xlsx file is created every night probably with a different file name every night). The cloumns in the cvs will be first name , last name, ExternalEmailAddress, OrganizationUnit. I will probably have a batch file run to delete any other excel or csv files in this folder before the new xlsx file is created
step two
To be able to run a scheduled powershell to automatically connect to exchange online without any interaction
I got as far as this but it keeps prompting for username and password:
Set-ExecutionPolicy RemoteSigned -Scope Currentuser
$credential = get-credential
Import-Module MSOnline
Connect-MsolService -Credential $credential
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "
https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $ExchangeSession
step three
Delete all of my contacts in exchange on line
Step four
Using the converted CSV file automatically import contacts to a exchange group (first name , Last name and email address only).
If the exchange group does not exist then create a group with the email address (groupname@example.com)
step five
All of the above will be a scheduled task from the on premises application server.
Background
My bespoke management system is constantly being updated on a daily basis with clients constantly being added and removed from distribution lists. This is becoming a nightmare to administer so I thought that if I could get my management system to export a report and then use that report to carry out the admin at night time it would save me hours of work each week.
I know its a hard one but I'm sure one or more of you have the knowledge(fingers crossed)
Many thanks
Simon
Many thanks for helping at my hour of need. Very kind of you.
Just to confirm would I be right in saying that once I have created the flder and txt on the root of c: the script should look like this;
Set-ExecutionPolicy RemoteSigned -Scope Currentuser
$sAMAccountName = "simon@x.com"
$securePW = Get-Content "C:\secure\creds.txt" | ConvertTo-SecureString
$credential = New-Object System.Management.Automati
Import-Module MSOnline
Connect-MsolService -Credential $credential
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $ExchangeSession
Regards
Simon