LUM.SfB.psm1
function format-hours{ param( $businessHours, $day, $prepend ) If(($businesshours."$($day)hours1".closetime.Totalminutes -eq 0) -and ($businesshours."$($day)hours2".closetime.Totalminutes -eq 1439)){ $x = "Open all day on $prepend" write-host $x -ForegroundColor Green return } If(($businesshours."$($day)hours1".closetime.Totalminutes -eq 1439) -and ($businesshours."$($day)hours2".closetime.Totalminutes -eq 0)){ $x = "Open all day on $prepend" write-host $x -ForegroundColor Green return } If(($businesshours."$($day)hours1".closetime.Totalminutes -eq $null) -and ($businesshours."$($day)hours2".closetime.Totalminutes -eq 1439)){ $x = "Open all day on $prepend" write-host $x -ForegroundColor Green return } If(($businesshours."$($day)hours1".closetime.Totalminutes -eq 1439) -and ($businesshours."$($day)hours2".closetime.Totalminutes -eq $null)){ $x = "Open all day on $prepend" write-host $x -ForegroundColor Green return } If(($businesshours."$($day)hours1".opentime.Totalminutes -eq $businesshours."$($day)hours1".closetime.Totalminutes) -and ($businesshours."$($day)hours2".opentime.Totalminutes -eq $businesshours."$($day)hours2".closetime.Totalminutes)){ $x = "Closed all day on $prepend" write-host $x -ForegroundColor Red return } If(($businesshours."$($day)hours1".opentime.Totalminutes -eq $businesshours."$($day)hours1".closetime.Totalminutes) -and ($businesshours."$($day)hours2".opentime.Totalminutes -ne $businesshours."$($day)hours2".closetime.Totalminutes)){ $openH2 = $businesshours."$($day)hours2".opentime.hours if($openH2 -lt 10){$openH2 = "0$($openH2.tostring())"} $openM2 = $businesshours."$($day)hours2".opentime.minutes if($openM2 -lt 10){$openM2 = "0$($openM2.tostring())"} $closeH2 = $businesshours."$($day)hours2".closetime.hours if($closeH2 -lt 10){$closeH2 = "0$($closeH2.tostring())"} $closeM2 = $businesshours."$($day)hours2".closetime.minutes if($closeM2 -lt 10){$closeM2 = "0$($closeM2.tostring())"} write-host "From $($openH2):$openM2 to $($closeH2):$closeM2 on $prepend" -ForegroundColor Cyan } If(($businesshours."$($day)hours1".opentime.Totalminutes -ne $businesshours."$($day)hours1".closetime.Totalminutes) -and ($businesshours."$($day)hours2".opentime.Totalminutes -eq $businesshours."$($day)hours2".closetime.Totalminutes)){ $openH1 = $businesshours."$($day)hours1".opentime.hours if($openH1 -lt 10){$openH1 = "0$($openH1.tostring())"} $openM1 = $businesshours."$($day)hours1".opentime.minutes if($openM1 -lt 10){$openM1 = "0$($openM1.tostring())"} $closeH1 = $businesshours."$($day)hours1".closetime.hours if($closeH1 -lt 10){$closeH1 = "0$($closeH1.tostring())"} $closeM1 = $businesshours."$($day)hours1".closetime.minutes if($closeM1 -lt 10){$closeM1 = "0$($closeM1.tostring())"} write-host "From $($openH1):$openM1 to $($closeH1):$closeM1 on $prepend" -ForegroundColor Cyan } If(($businesshours."$($day)hours1".opentime.Totalminutes -ne $businesshours."$($day)hours1".closetime.Totalminutes) -and ($businesshours."$($day)hours2".opentime.Totalminutes -ne $businesshours."$($day)hours2".closetime.Totalminutes)){ $openH1 = $businesshours."$($day)hours1".opentime.hours if($openH1 -lt 10){$openH1 = "0$($openH1.tostring())"} $openM1 = $businesshours."$($day)hours1".opentime.minutes if($openM1 -lt 10){$openM1 = "0$($openM1.tostring())"} $closeH1 = $businesshours."$($day)hours1".closetime.hours if($closeH1 -lt 10){$closeH1 = "0$($closeH1.tostring())"} $closeM1 = $businesshours."$($day)hours1".closetime.minutes if($closeM1 -lt 10){$closeM1 = "0$($closeM1.tostring())"} $openH2 = $businesshours."$($day)hours2".opentime.hours if($openH2 -lt 10){$openH2 = "0$($openH2.tostring())"} $openM2 = $businesshours."$($day)hours2".opentime.minutes if($openM2 -lt 10){$openM2 = "0$($openM2.tostring())"} $closeH2 = $businesshours."$($day)hours2".closetime.hours if($closeH2 -lt 10){$closeH2 = "0$($closeH2.tostring())"} $closeM2 = $businesshours."$($day)hours2".closetime.minutes if($closeM2 -lt 10){$closeM2 = "0$($closeM2.tostring())"} write-host "From $($openH1):$openM1 to $($closeH1):$closeM1 and from $($openH2):$openM2 to $($closeH2):$closeM2 on $prepend" -ForegroundColor Cyan } } # This Function Returns the Selected Value and Closes the Form function Return-DropDown { if ($DropDown.SelectedItem -eq $null){ $DropDown.SelectedItem = $DropDown.Items[0] $script:Choice = $DropDown.SelectedItem.ToString() $Form.Close() } else{ $script:Choice = $DropDown.SelectedItem.ToString() $Form.Close() } } function SelectGroup{ [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") $Form = New-Object System.Windows.Forms.Form $Form.width = 500 $Form.height = 150 $Form.Text = �DropDown� $DropDown = new-object System.Windows.Forms.ComboBox $DropDown.Location = new-object System.Drawing.Size(200,10) $DropDown.Size = new-object System.Drawing.Size(260,30) [void] $DropDown.Items.Add("Multiple_Response_Groups") ForEach ($Item in $DropDownArray) { [void] $DropDown.Items.Add($Item) } $Form.Controls.Add($DropDown) $DropDownLabel = new-object System.Windows.Forms.Label $DropDownLabel.Location = new-object System.Drawing.Size(10,10) $DropDownLabel.size = new-object System.Drawing.Size(100,40) $DropDownLabel.Text = "Select Group:" $Form.Controls.Add($DropDownLabel) $Button = new-object System.Windows.Forms.Button $Button.Location = new-object System.Drawing.Size(100,50) $Button.Size = new-object System.Drawing.Size(100,20) $Button.Text = "Select an Item" $Button.Add_Click({Return-DropDown}) $form.Controls.Add($Button) $form.ControlBox = $false $Form.Add_Shown({$Form.Activate()}) [void] $Form.ShowDialog() return $script:choice } function Get-RgsWorkflow{ <# .SYNOPSIS Displays one or more RGS workflows .DESCRIPTION Shows Workflow to queue to group with all parameters .EXAMPLE Get-RgsWorkflow .INPUTS Selection of RGSWorkflow Name .OUTPUTS Report on workflow in Write-Host .NOTES +---------------------------------------------------------------------------------------------+ | ORIGIN STORY | +---------------------------------------------------------------------------------------------+ | DATE : 2018.10.29 | AUTHOR : Michael L�rsen | E-Mail : michael.luersen@mondaycoffee.com +---------------------------------------------------------------------------------------------+ #> if(!(get-module SkypForBusiness)){ Import-Module SkypeForBusiness } if($psise -ne $null){ Write-Warning "the formatting looks better when you run this cmd-let from the Console instead ISE" } [array]$DropDownArrayItems = (get-csrgsworkflow).name [array]$DropDownArray = $DropDownArrayItems | sort $Group = $null $Group = SelectGroup while ($Group -like ""){ $Group = SelectGroup } if($group -eq "Multiple_Response_Groups"){ $prefix = read-host -Prompt "Type the first letter(s) of the response group for which to return results" $rgsworkflows = get-csrgsworkflow | Where-Object{$_.name -like "$prefix*"} }else{ $rgsworkflows = get-csrgsworkflow -name $group } foreach($rgsworkflow in $rgsworkflows){ $rgsqueue = Get-CsRgsQueue | Where-Object{$_.identity.instanceID.guid -eq $rgsworkflow.DefaultAction.QueueID.InstanceId} $rgsgroups = @() foreach($agentGroup in $rgsqueue.AgentGroupIDList){ $rgsgroups += Get-CsRgsAgentGroup | where-object{$_.identity.instanceid.guid -eq $agentgroup.instanceID.Guid} } write-host "`n======== GENERAL INFO ========" -BackgroundColor Gray if($Rgsworkflow.Active -eq $true){ write-host "workflow is active" -ForegroundColor Green }else{ write-host "workflow is inactive" -ForegroundColor Gray } if($Rgsworkflow.EnabledForFederation -eq $true){ write-host "workflow is enabled for federation" -ForegroundColor Green }else{ write-host "workflow is not enabled for federation" -ForegroundColor Gray } if($Rgsworkflow.Anonymous -eq $true){ write-host "workflow is enabled for agent anonymity" -ForegroundColor Green }else{ write-host "workflow is not enabled for agent anonymity" -ForegroundColor Gray } write-host "Sip Address: `t`t $($rgsworkflow.primaryuri)" -ForegroundColor Cyan write-host "Displayname: `t`t $($rgsworkflow.name)" -ForegroundColor Cyan write-host "Telephone Number: `t $($rgsworkflow.Lineuri)" -ForegroundColor Cyan write-host "DisplayNumber: `t`t $($rgsworkflow.DisplayNumber)" -ForegroundColor Cyan if($rgsworkflow.Description -ne $null){ write-host "Description: `t`t $($rgsworkflow.Description)" -ForegroundColor Cyan } if($Rgsworkflow.managed -eq $true){ write-host "workflow type is managed by:" -ForegroundColor Green foreach($manager in $rgsworkflow.ManagersByUri){ write-host "`t`t`t$manager" -ForegroundColor Cyan } }else{ write-host "workflow type is unmanaged" -ForegroundColor Gray } write-host "`n======== Language ========" -BackgroundColor Gray write-host "Workflow Language: `t $($rgsworkflow.Language)" -ForegroundColor Cyan write-host "`n======== Welcome Message ========" -BackgroundColor Gray if($rgsworkflow.DefaultAction.Prompt.AudioFilePrompt -ne $null){ write-host "Audiofile: `t`t $($rgsworkflow.DefaultAction.Prompt.AudioFilePrompt)" -ForegroundColor Cyan } if($rgsworkflow.DefaultAction.Prompt.TextToSpeechPrompt -ne $null){ write-host "Text to Speech: `t`t $($rgsworkflow.DefaultAction.Prompt.TextToSpeechPrompt)" -ForegroundColor Cyan } write-host "`n======== Business Hours ========" -BackgroundColor Gray if($rgsworkflow.NonBusinessHoursAction.Prompt.AudioFilePrompt -ne $null){ write-host "Message outside of business hours - Audiofile: `t`t $($rgsworkflow.NonBusinessHoursAction.Prompt.AudioFilePrompt)" -ForegroundColor Cyan } if($($rgsworkflow.NonBusinessHoursAction.Prompt.TextToSpeechPrompt).length -ne 0){ write-host "Message outside of business hours - Text to Speech: `t`t $($rgsworkflow.NonBusinessHoursAction.Prompt.TextToSpeechPrompt)" -ForegroundColor Cyan } write-host "Action outside of business hours: `t $($rgsworkflow.NonBusinessHoursAction.action)" -ForegroundColor Cyan $businesshours = Get-CsRgsHoursOfBusiness -Identity $rgsworkflow.BusinessHoursID if(($businesshours.MondayHours1.OpenTime -eq $businesshours.TuesdayHours1.OpenTime) -and ($businesshours.MondayHours1.CloseTime -eq $businesshours.TuesdayHours1.CloseTime) -and ($businesshours.MondayHours2.OpenTime -eq $businesshours.TuesdayHours2.OpenTime) -and ($businesshours.MondayHours2.CloseTime -eq $businesshours.TuesdayHours2.CloseTime)){ if(($businesshours.TuesdayHours1.OpenTime -eq $businesshours.WednesdayHours1.OpenTime) -and ($businesshours.TuesdayHours1.CloseTime -eq $businesshours.WednesdayHours1.CloseTime) -and ($businesshours.TuesdayHours2.OpenTime -eq $businesshours.WednesdayHours2.OpenTime) -and ($businesshours.TuesdayHours2.CloseTime -eq $businesshours.WednesdayHours2.CloseTime)){ if(($businesshours.WednesdayHours1.OpenTime -eq $businesshours.ThursdayHours1.OpenTime) -and ($businesshours.WednesdayHours1.CloseTime -eq $businesshours.ThursdayHours1.CloseTime) -and ($businesshours.WednesdayHours2.OpenTime -eq $businesshours.ThursdayHours2.OpenTime) -and ($businesshours.WednesdayHours2.CloseTime -eq $businesshours.ThursdayHours2.CloseTime)){ if(($businesshours.ThursdayHours1.OpenTime -eq $businesshours.FridayHours1.OpenTime) -and ($businesshours.ThursdayHours1.CloseTime -eq $businesshours.FridayHours1.CloseTime) -and ($businesshours.ThursdayHours2.OpenTime -eq $businesshours.FridayHours2.OpenTime) -and ($businesshours.ThursdayHours2.CloseTime -eq $businesshours.FridayHours2.CloseTime)){ if(($businesshours.FridayHours1.OpenTime -eq $businesshours.SaturdayHours1.OpenTime) -and ($businesshours.FridayHours1.CloseTime -eq $businesshours.SaturdayHours1.CloseTime) -and ($businesshours.FridayHours2.OpenTime -eq $businesshours.SaturdayHours2.OpenTime) -and ($businesshours.FridayHours2.CloseTime -eq $businesshours.SaturdayHours2.CloseTime)){ if(($businesshours.SaturdayHours1.OpenTime -eq $businesshours.SundayHours1.OpenTime) -and ($businesshours.SaturdayHours1.CloseTime -eq $businesshours.SundayHours1.CloseTime) -and ($businesshours.SaturdayHours2.OpenTime -eq $businesshours.SundayHours2.OpenTime) -and ($businesshours.SaturdayHours2.CloseTime -eq $businesshours.SundayHours2.CloseTime)){ format-hours -businessHours $businesshours -day "Sunday" -prepend "Monday - Sunday" }Else{ format-hours -businessHours $businesshours -day "Saturday" -prepend "Monday - Saturday" format-hours -businessHours $businesshours -day "Sunday" -prepend "Sunday: " } }Else{ format-hours -businessHours $businesshours -day "Friday" -prepend "Monday - Friday" format-hours -businessHours $businesshours -day "Saturday" -prepend "Saturday" format-hours -businessHours $businesshours -day "Sunday" -prepend "Sunday" } }Else{ format-hours -businessHours $businesshours -day "Thursday" -prepend "Monday - Thursday" format-hours -businessHours $businesshours -day "Friday" -prepend "Friday" format-hours -businessHours $businesshours -day "Saturday" -prepend "Saturday" format-hours -businessHours $businesshours -day "Sunday" -prepend "Sunday" } }Else{ format-hours -businessHours $businesshours -day "Wednesday" -prepend "Monday - Wednesday" format-hours -businessHours $businesshours -day "Thursday" -prepend "Thursday" format-hours -businessHours $businesshours -day "Friday" -prepend "Friday" format-hours -businessHours $businesshours -day "Saturday" -prepend "Saturday" format-hours -businessHours $businesshours -day "Sunday" -prepend "Sunday" } }Else{ format-hours -businessHours $businesshours -day "Tuesday" -prepend "Monday - Wednesday" format-hours -businessHours $businesshours -day "Wednesday" -prepend "Wednesday" format-hours -businessHours $businesshours -day "Thursday" -prepend "Thursday" format-hours -businessHours $businesshours -day "Friday" -prepend "Friday" format-hours -businessHours $businesshours -day "Saturday" -prepend "Saturday" format-hours -businessHours $businesshours -day "Sunday" -prepend "Sunday" } } Else{ format-hours -businessHours $businesshours -day "Monday" -prepend "Monday" format-hours -businessHours $businesshours -day "Tuesday" -prepend "Tuesday" format-hours -businessHours $businesshours -day "Wednesday" -prepend "Wednesday" format-hours -businessHours $businesshours -day "Thursday" -prepend "Thursday" format-hours -businessHours $businesshours -day "Friday" -prepend "Friday" format-hours -businessHours $businesshours -day "Saturday" -prepend "Saturday" format-hours -businessHours $businesshours -day "Sunday" -prepend "Sunday" } write-host "`n======== Holidays ========" -BackgroundColor Gray foreach($item in $rgsworkflow.HolidaySetIDList){ $service = (get-csservice | ?{$_.serviceID -eq $($item.ServiceId)}).identity $identity = $service + "/" + $item.instanceid write-host (Get-CsRgsHolidaySet -Identity $identity).name -ForegroundColor Cyan } write-host "`n======== Connected queue ========" -BackgroundColor Gray $rgsqueuename = (get-csrgsqueue -Identity $rgsworkflow.DefaultAction.QueueID).name write-host $rgsqueuename -ForegroundColor Cyan write-host "`n======== Music on Hold ========" -BackgroundColor Gray write-host $rgsworkflow.CustomMusicOnHoldFile.OriginalFileName -ForegroundColor Cyan write-host "`n======== Queue settings ========" -BackgroundColor Gray $rgsqueue = Get-CsRgsQueue -Name $rgsqueuename write-host "Name: `t`t`t`t`t" $rgsqueue.name -ForegroundColor Cyan if($rgsqueue.Description -ne $null){ write-host "Description: `t`t`t`t" $rgsqueue.Description -ForegroundColor Cyan } if($rgsqueue.TimeoutThreshold -ne $null){ write-host "Queue Timeout Seconds: `t`t`t" $rgsqueue.TimeoutThreshold -ForegroundColor Cyan write-host "Queue Timeout Action: `t`t`t" $rgsqueue.Timeoutaction.action -ForegroundColor Cyan if($rgsqueue.Timeoutaction.Prompt -ne $null){ write-host "Queue Timeout Prompt: `t`t`t" $rgsqueue.Timeoutaction.Prompt -ForegroundColor Cyan } if($rgsqueue.Timeoutaction.Question -ne $null){ write-host "Queue Timeout Question: `t`t`t" $rgsqueue.Timeoutaction.Question -ForegroundColor Cyan } if($rgsqueue.Timeoutaction.QueueID -ne $null){ $rgsTimeoutqueuename = (get-csrgsqueue -Identity $rgsqueue.Timeoutaction.QueueID).name write-host "Queue Timeout Forward Queue: `t`t" $rgsTimeoutqueuename -ForegroundColor Cyan } if($rgsqueue.Timeoutaction.Uri -ne $null){ write-host "Queue Timeout Forward to: `t`t" $rgsqueue.Timeoutaction.Uri -ForegroundColor Cyan } } If($rgsqueue.OverflowThreshold -ne $null){ write-host "Queue Overflow Threshold: `t`t" $rgsqueue.OverflowThreshold -ForegroundColor Cyan if($rgsqueue.OverflowCandidate -ne $null){ write-host "Queue Overflow Candidate: `t`t" $rgsqueue.OverflowCandidate -ForegroundColor Cyan } if($rgsqueue.OverflowAction.Prompt -ne $null){ write-host "Queue Overflow Prompt: `t`t" $rgsqueue.OverflowAction.Prompt -ForegroundColor Cyan } if($rgsqueue.OverflowAction.Question -ne $null){ write-host "Queue Overflow Question: `t`t" $rgsqueue.OverflowAction.Question -ForegroundColor Cyan } if($rgsqueue.OverflowAction.QueueID -ne $null){ $rgsOverflowqueuename = (get-csrgsqueue -Identity $rgsqueue.OverflowAction.QueueID).name write-host "Queue Overflow Forward Queue: `t`t`t" $rgsOverflowqueuename -ForegroundColor Cyan } if($rgsqueue.OverflowAction.Uri -ne $null){ write-host "Queue Overflow Forward to: `t`t" $rgsqueue.OverflowAction.Uri -ForegroundColor Cyan } } write-host "`n======== Groups & Agents ========" -BackgroundColor Gray foreach($item in $rgsqueue.AgentGroupIDList){ $service = (get-csservice | ?{$_.serviceID -eq $($item.ServiceId)}).identity $identity = $service + "/" + $item.instanceid $agentgroup = (Get-CsRgsAgentGroup -Identity $identity) write-host "Agent group Name: `t`t`t" $agentgroup.name -ForegroundColor Cyan write-host "Agent group Alert Time: `t`t" $agentgroup.AgentAlertTime -ForegroundColor Cyan if($agentGroup.Description -ne $null){ write-host "Agent group Description: `t" $agentgroup.Description -ForegroundColor Cyan } write-host "Agent group participation policy: `t" $agentgroup.ParticipationPolicy -ForegroundColor Cyan write-host "Agent group routing method: `t`t" $agentgroup.RoutingMethod -ForegroundColor Cyan $x = $false foreach($member in $agentGroup.agentsbyURI){ $agent = $member.ToString() if($x -eq $false){ $x = $true write-host "Agent group members: `t`t`t" $agent.Replace("sip:","") -ForegroundColor Green }else{ write-host "`t`t`t`t`t" $agent.Replace("sip:","") -ForegroundColor Green } } } } write-host "`n`n" Read-Host -Prompt "Press Enter to exit" } |