need assistance with a powershell script

hello, can someone provide a way that I can add logic to this script to add in a list of room mailboxes from an input txt file.


here is the current script that works against a single room, we would like to add logic so that this runs against the list on an input txt file:

$internalmessage = get-content internalmessage.txt
$externalmessage = get-content externalmessage.txt

Set-MailboxAutoReplyConfiguration test-roombooking -AutoReplyState enabled -ExternalAudience all -InternalMessage "$internalmessage" -ExternalMessage "$externalmessage"

Open in new window


thx in advance.
siber1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nashiookaCommented:
It depends.  If you want your internal and external messages customized for each room.  If the messages are to remain the same you can just pipe in the rooms from a get-content

Get-Content Rooms.txt | Set-MailboxAutoReplyConfiguration ...

Now if you want customization I would put a replaceable string in your internal/external message files.  I usually do something like %room% then loop through the rooms replacing that string in each command you run something like:

$internalmessage = get-content internalmessage.txt
$externalmessage = get-content externalmessage.txt
$Rooms = Get-Content Rooms.txt

ForEach($Room in $Rooms)
{
Set-MailboxAutoReplyConfiguration $Room -AutoReplyState enabled `
	-ExternalAudience all `
	-InternalMessage $internalmessage.Replace("%room%",$room) `
	-ExternalMessage $externalmessage.Replace("%room%",$room)
}

Open in new window


You can do a lot more with this.  In particular you can setup your inputs differently.  Perhaps a CSV file containing all the settings you want for a particular room.  Or even a hash table with the settings.  So let me know if I don't have this right.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
siber1Author Commented:
hi nashiooka, thanks for the code suggestion, I tried the code you provided but the room mailboxes are not being updated. can you let me know if the variables need to be adjusted?  thx
nashiookaCommented:
Are you getting an error?  How did you format the rooms.txt file?  You should have one room per line.  Also make sure your Internal & External message files are one long like, otherwise the vars will be array and the replace method won't be available.

Let me know.
siber1Author Commented:
hi Nashiooka,  its working now, the script was perfect, It was a mistake on my end.  thx again!
siber1Author Commented:
excellent, just what I was looking for.  thx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.