question

AMaDAC-0347 avatar image
0 Votes"
AMaDAC-0347 asked ·

Running Get and Set command to set the value

For Example I run:


Get-CsTeamsMeetingPolicy -Identity Global
with return value of (sample only)

AllowMeetNow : True
MeetingChatEnabledType : Disabled

And for every value should be equal to set command

Set-CsTeamsMeetingPolicy -AllowMeetNow $False -MeetingChatEnabledType Disabled

How do I write if and else statement with parameters to set the -AllowMeetnow to $false and -MeetingChatEnabledType

Please advise or walk through me to forum or link.

office-teams-windows-itprowindows-server-powershell
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered ·

Hi,

Why do you want an if statement since only the set command is needed to be executed?

 $global = Get-CsTeamsMeetingPolicy -Identity Global
 Set-CsTeamsMeetingPolicy -AllowMeetNow $global.AllowMeetNow -MeetingChatEnabledType $global.MeetingChatEnabledType 

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 3 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

My main goal are to Get, Compare and Set the settings automatically.

So basically the script will run 24/7 and when it detects the current settings are different from the desired settings it will execute the Set Command.

For example is the above settings or this one too.

-AllowMeetNow is True in Get command but the desired setting is False so Set command should execute and make it False then.

Please let me know if this make sense or let me hear your insight.

Thank you.

0 Votes 0 ·

Does this meet your needs? It sets Global to the desired values if the settings are different. You can run this script as a scheduled task.

 $desired = @{
     AllowMeetNow =  $false
     MeetingChatEnabledType = "Disabled"
 }
 $global = Get-CsTeamsMeetingPolicy -Identity Global
 if(($global.AllowMeetNow -ne $desired.AllowMeetNow) -or ($global.MeetingChatEnabledType -ne $desired.MeetingChatEnabledType))
 {
     Set-CsTeamsMeetingPolicy -Identity Global -AllowMeetNow $desired.AllowMeetNow -MeetingChatEnabledType $desired.MeetingChatEnabledType  
 }

1 Vote 1 ·

YOU ROCK!!

0 Votes 0 ·