need assistance with a powershell script

siber1
siber1 used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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.

Author

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
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.

Author

Commented:
hi Nashiooka,  its working now, the script was perfect, It was a mistake on my end.  thx again!

Author

Commented:
excellent, just what I was looking for.  thx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial