Automation of Conference booking in Cisco TMS with Powershell
The plot for the assignment 🙂
We got a question if we could automate the booking of Cisco TMS Video Conference for a customer that before this script managed about 2000 booking a month by clicking i Cisco TMS portal. One of the requirement for the automation was Powershell.
The first thing was to start talking to Cisco TMS thru API and for that we used the application Postman. In the documentation for Cisco TMS you will find some XML exemples that you send thru Postman and get responses you need to create an automated booking of Video Conference with Powershell.
The first delivery of scripts contained multiple Powershell-script and lots of XML-files that the scripts imported. And beyond the XML-files and Powershell-scripts the scripts also created and deleted multiple XML-files. In the last delivery (in this post) we have modified the script-package only to contain three files, mainscript, passwordscript and config-XML.
The result for the customer…
After the script for the first two month the script generated 4000 automated bookings saving multiple hours for the Servicedesk 🙂
The script-collection.
Like a said the script-collection consist of three files. The config.XML holds all configuration for the scripts. The passwordscripts generates crypted password for the useraccount to be used in the automation and last but not least the mainscript where all good stuff happens.
Config.XML – Notes
- TimeAdjust – You need to check that the mail going to client who requested a Video Conference has the same time set in Cisco TMS portal.
- DaysToSave – Numbers of days you want to save your logfiles.
- RowInFile – This one are the tricky one. When you make a booking the Cisco TMS sends back a file where the phonenumber to call. We noticed that it didn´t match Customer Cisco TMS and our Test Cisco TMS. You need to count and find the rownumber where your phonenumber exist.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?xml version="1.0" encoding="utf-8"?> <ConfigTMS> <!--Emailsettings--> <EmailFrom>Your no-reply address</EmailFrom> <EmailSMTP>Your SMTP-server</EmailSMTP> <EmailSubject>Your subject in your mail</EmailSubject> <!--Settings for XML Accounts and API and timeadjust--> <pathCiscoTMSAPI>"Your address to Cisco TMS server "/bookingservice.asmx?wsdl</pathCiscoTMSAPI> <username>tms-api.test</username> <pathPwdFile>keys/cryptfileRemote.txt</pathPwdFile> <TimeAdjust>-1</TimeAdjust> <!-- -1=withdraw one hour 1=forward one hour --> <!--Logfile, Name on the tempfolder --> <Logfolder>Logs</Logfolder> <TempFolder>temp</TempFolder> <DaysToSave>-15</DaysToSave> <!--Settings for participants--> <ParticipantCallType>IP Video -></ParticipantCallType> <ParticipantDefaultName>Deltagare</ParticipantDefaultName> <!--Settings for domain and phonenumbers--> <JoinUrl>Your webaddress where your connect to the conference</JoinUrl> <Domain>Your domain</Domain> <Phonenumber>01012345678</Phonenumber> <PhonenumberINT>+461012345678</PhonenumberINT> <!--Settings for extracting the number to call in--> <!--Row in file with the value (actual row -1)--> <RowInFile>14</RowInFile> </ConfigTMS> |
New-CryptedPasswordFile.ps1 – Notes
Your should not send your password in cleartext instead you need to create a crypted file containing the password. This script is for startup first time when you start to implement the script. Note! If you move the script from one enviroment to another you need to create a new crypted file because when you create a crypted file it use the enviroment as reference.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<# .Synopsis Crypted Passwordfile .DESCRIPTION The script ask for path where to save a crypted passwordfile to be used in automation where elevated credential is needed, .EXAMPLE New-CryptedPasswordFile -Filepath .\CryptedPasswordfilename.txt .NOTES =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.183 Created on: 1/27/2021 10:35 AM Updated on: 1/27/2021 10:35 AM Created by: Christian Damberg, Sebastian Thörngren Organization: Cygate AB Filename: New-CryptedPasswordFile.ps1 =========================================================================== #> function New-CryptedPasswordFile { [CmdletBinding()] [Alias()] [OutputType([int])] Param ( # Param1 help description [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] $Filepath ) Begin { } Process { $credential = Get-Credential $credential.Password | ConvertFrom-SecureString | Set-Content $Filepath } End { } } New-CryptedPasswordFile |
New-CiscoTMSConference.ps1 – Notes
Here you have the main scriptfile…
The script starts with reading the config-file for info about logfile, path to temp.
Next step the username and password are imported, be sure you give the user minimum rights to communicate with Cisco TMS.
Now it´s time to send a request to the Cisco TMS to get the default values the system has for your organisation. This values will be stored in a virtual xml-file.
After reading the configfile, getting the default values you now will start to create the xml-file with everything you need to send a request for an Video meeting.
The very first time you send for the default values you will get a session id. In the script under the section when you create a xml-file for a request the session id are “0” (zero). Here is the only place in the script where you enter a value manually…the session id you get when asking for default value. This session id will you use for every request.
There is a timeout how long you can use a session id and that is 46 minutes. The script handles that by catching the errorcode when the timeout happens then the script will request for a temporary session id. Next time the scripts run it will test your default session id and request a temporary session id until your default session id is open for business again.
Next on the list to do in the script is to catch the response and extract important info like number to call, pin-code and so on.. and then create a mail with all info to send to the requester.
Done!
The script register everything in the logfile and make sure that the logfile don´t fill up the disk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
<# .SYNOPSIS A brief description of the New-CiscoTMSConference.ps1 file. .DESCRIPTION A detailed description of the New-CiscoTMSConference.ps1 file. .PARAMETER Inputstart A description of the Inputstart parameter. .PARAMETER Inputlength A description of the Inputlength parameter. .PARAMETER Bookingnumber A description of the Bookingnumber parameter. .PARAMETER BookedBy A description of the BookedBy parameter. .PARAMETER ExtDeltagare A description of the ExtDeltagare parameter. .PARAMETER TestOnly Generate XML only .NOTES =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.182 Created on: 02/04/2021 1:50 PM Created by: Christian Damberg, Sebastian Thörngren Organization: Cygate AB Filename: New-CiscoTMSConference.ps1 =========================================================================== #> # Inputvalues needed to send a request for Conference. [CmdletBinding()] param ( [Parameter(Mandatory = $true, HelpMessage = 'yyyy-MM-dd hh:mm:ss')] [datetime]$Inputstart, [Parameter(Mandatory = $true, HelpMessage = 'Meeting length in hours')] [string]$Inputlength = '12', [Parameter(Mandatory = $true)] [string]$Bookingnumber, [Parameter(Mandatory = $true, HelpMessage = 'the one who booked the conference')] [string]$BookedBy, [Parameter(Mandatory = $true, HelpMessage = 'ServiceNumber of request')] [string]$BillingCode ) # info about scriptversion and date $scriptversion = '1.6' $scriptdate = '2021-04-07' ################################################################################################ # Path to configfile for script $absPath = Join-Path $PSScriptRoot "/CiscoTMSConfig.XML" # Get content of Configfile [xml]$config = Get-Content -Path $absPath ################################################################################################ ################################################################################################ # # Functions in script and creation of temp- and log-folder # ################################################################################################ $logfolder = Join-Path $PSScriptRoot $config.ConfigTMS.logfolder $Today = get-date -Format 'yyyy-MM-dd' $logfile = "$logfolder\$Today.log" # Function to write to logfile Function Write-Log { [CmdletBinding()] Param( [Parameter(Mandatory=$False)] [ValidateSet("INFO","WARN","ERROR","FATAL","DEBUG")] [String] $Level = "INFO", [Parameter(Mandatory=$True)] [string] $Message ) $Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") $Line = "$Stamp $Level $Message" Add-Content $logfile -Value $Line } ################################################################################################ # Log-folder ################################################################################################ $logfolder = Join-Path $PSScriptRoot $config.ConfigTMS.logfolder # create logfolder if not exist if (-not (Test-Path -path $logfolder -pathtype Container)) { try { New-Item -Path $logfolder -ItemType Directory -ErrorAction Stop | Out-Null #-Force } catch { Write-host 'Cant create logfile' exit } } # Get todays date to name the logfile $Today = get-date -Format 'yyyy-MM-dd' # Path to todays logfile $logfile = "$logfolder\$Today.log" write-log -Level INFO -Message "Logfolder $logfolder" # Remove old logfiles $DaysToSave = $config.ConfigTMS.DaysToSave $limit = (Get-Date).AddDays($DaysToSave) $path = $logfolder # Delete files older than the $limit. Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force ################################################################################################ # # Start writing to logfile # ################################################################################################ write-log -Level INFO -Message "################################################################################################" write-log -Level INFO -Message "Scriptversion: $scriptversion" write-log -Level INFO -Message "Scriptdate: $scriptdate" write-log -Level INFO -Message "################################################################################################" ################################################################################################ # Temp-folder ################################################################################################ # Path to tempfolder $Tempfolder = Join-Path $PSScriptRoot $config.ConfigTMS.Tempfolder # Create tempfolder if not exist if (-not (Test-Path -path $Tempfolder -pathtype Container)) { try { New-Item -Path $Tempfolder -ItemType Directory -ErrorAction Stop | Out-Null #-Force } catch { #Write-Error -Message "Unable to create directory '$Tempfolder'. Error was: $_" -ErrorAction Stop Write-log -Level ERROR -Message "Unable to create directory '$Tempfolder'. Error was: $_" write-log -Level ERROR -Message "Errorcode 100" Write-host "100" exit } write-log -level INFO -Message "Successfully created tempfolder $Tempfolder" } else { write-log -level INFO -Message "Directory already exist $Tempfolder" } # Write to log write-log -Level INFO -Message "Path to config: $abspath" write-log -Level INFO -Message "psscriptroot: $psscriptroot" ################################################################################################ # # Import user account password from crypted file # ################################################################################################ # User with rights to run API on Cisco TMS $username = $config.ConfigTMS.username # Write to log write-log -Level INFO -Message "Account running the script: $username" # Import password from crypted passwordfile $url = Join-Path $PSScriptRoot $config.ConfigTMS.pathPwdFile # Write to log write-log -Level INFO -Message "path to passwordfile: $url" # Read passwordfile och convert to string $encrypted = Get-Content $url | ConvertTo-SecureString $UnsecurePassword = (New-Object PSCredential "user",$encrypted).GetNetworkCredential().Password # Create variable with username and password $credential = New-Object System.Management.Automation.PsCredential($username, $encrypted) ################################################################################################ # # Send Request to get default conference values # ################################################################################################ # XML file used to extract default-values from Cisco TMS [System.Xml.XmlDocument] $original_GetDefaultConferenceXML = @" <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <ExternalAPIVersionSoapHeader xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <ClientVersionIn>15</ClientVersionIn> <ClientIdentifierIn>string</ClientIdentifierIn> <ClientLatestNamespaceIn>string</ClientLatestNamespaceIn> <NewServiceURL>string</NewServiceURL> <ClientSession>string</ClientSession> </ExternalAPIVersionSoapHeader> </soap12:Header> <soap12:Body> <GetDefaultConference xmlns="http://tandberg.net/2004/02/tms/external/booking/" /> </soap12:Body> </soap12:Envelope> "@ # Post request to get default values of an conference-request. $apipath = $config.ConfigTMs.pathCiscoTMSAPI write-log -Level INFO -Message "Address to Cisco APi $apipath" try { $PostRequest = Invoke-WebRequest -Uri $config.ConfigTMs.pathCiscoTMSAPI -Body $original_GetDefaultConferenceXML -ContentType 'text/xml' -Method POST -Credential $credential -skiphttpErrorcheck } catch { Write-Log -level ERROR -Message "$error[0].InvocationInfo.line" write-log -Level ERROR -Message "Errorcode 200.1" Write-host "200.1" exit } # Read XML-response of default values to be used when POST a request for a Conference [xml]$ResultXML_GetDefaultConference = $PostRequest.Content ################################################################################################ ################################################################################################ # This section if for create a xml-file used in the end of this section to post a request to # the API for Cisco TMS ################################################################################################ ################################################################################################ ################################################################################################ # # Create Request.xml with value from default Conference # ################################################################################################ # Variable HEADER $conferenceid = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.ConferenceId $SendConfirmationMail = 'true' $ExcludeConferenceInformation = 'false' $ClientLanguage = 'en' $ClientVersionIn = '15' $ClientIdentifierIn = 'string' $ClientLatestNamespaceIn = 'String' $NewServiceURL = 'string' # Variable from input # Starttime modified with value from config to adjust for timezone $StartTimeModified = $Inputstart.AddHours($config.configtms.timeadjust) # Starttime for meeting $starttimeUTC = $StartTimeModified.ToString('yyyy-MM-dd HH:mm:ssZ') $starttimeToMail = $inputstart.ToString('yyyy-MM-dd HH:mm') # How many hours $Meetingtime = $StartTimeModified.AddHours($InputLength) $endtimeToMail = $inputstart.AddHours($Inputlength) # End of meeting $endtimeUTC = $Meetingtime.ToString('yyyy-MM-dd HH:mm:ssZ') $endtimeToMailformat = $endtimeToMail.ToString('yyyy-MM-dd HH:mm') $Title = $Bookingnumber # Variable BODY $ClientSession = '0' $OwnerId = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.OwnerId $OwnerUserName = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.OwnerUserName $OwnerFirstName = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.OwnerFirstName $OwnerLastName = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.OwnerLastName $OwnerEmailAddress = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.OwnerEmailAddress $ConferenceType = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.ConferenceType $Bandwidth = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.Bandwidth $PictureMode = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.PictureMode $Encrypted = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.Encrypted $DataConference = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.DataConference $Password = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.Password $ShowExtendOption = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.ShowExtendOption $ISDNRestrict = $ResultXML_GetDefaultConference.Envelope.Body.GetDefaultConferenceResponse.GetDefaultConferenceResult.ISDNRestrict $NameOrNumber = $config.configtms.ParticipantDefaultName $ParticipantCallType = $config.configtms.ParticipantCallType ################################################################################################ # XML file used to post for booking of conference [System.Xml.XmlDocument] $PostConferenceResult = @" <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <ContextHeader xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <SendConfirmationMail>$SendConfirmationMail</SendConfirmationMail> <ExcludeConferenceInformation>$ExcludeConferenceInformation</ExcludeConferenceInformation> <ClientLanguage>$ClientLanguage</ClientLanguage> </ContextHeader> <ExternalAPIVersionSoapHeader xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <ClientVersionIn>$ClientVersionIn</ClientVersionIn> <ClientIdentifierIn>$ClientIdentifierIn</ClientIdentifierIn> <ClientLatestNamespaceIn>$ClientLatestNamespaceIn</ClientLatestNamespaceIn> <NewServiceURL>$NewServiceURL</NewServiceURL> <ClientSession>$ClientSession</ClientSession> </ExternalAPIVersionSoapHeader> </soap12:Header> <soap12:Body> <SaveConference xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <Conference> <ConferenceID>$conferenceid</ConferenceID> <Title>$title</Title> <StartTimeUTC>$starttimeUTC</StartTimeUTC> <EndTimeUTC>$endtimeUTC</EndTimeUTC> <OwnerId>$ownerID</OwnerId> <OwnerUserName>$OwnerUserName</OwnerUserName> <OwnerFirstName>$OwnerFirstName</OwnerFirstName> <OwnerLastName>$OwnerLastName</OwnerLastName> <OwnerEmailAddress>$OwnerEmailAddress</OwnerEmailAddress> <ConferenceType>$ConferenceType</ConferenceType> <Bandwidth>$Bandwidth</Bandwidth> <PictureMode>$PictureMode</PictureMode> <Encrypted>$Encrypted</Encrypted> <DataConference>$DataConference</DataConference> <ShowExtendOption>$ShowExtendOption</ShowExtendOption> <Password>$Password</Password> <BillingCode>$billingcode</BillingCode> <ISDNRestrict>$ISDNRestrict</ISDNRestrict> <Participants> <Participant> <NameOrNumber>$NameOrNumber</NameOrNumber> <ParticipantCallType>$ParticipantCallType</ParticipantCallType> </Participant> </Participants> </Conference> </SaveConference> </soap12:Body> </soap12:Envelope> "@ ################################################################################################ # # POST Conference Request and get Response if Error 500, get new ClienSessionID # ################################################################################################ # POST a request for an Conference try { $PostRequestNewConference = Invoke-WebRequest -Uri $config.ConfigTMs.pathCiscoTMSAPI -Body $PostConferenceResult -ContentType 'text/xml' -Method POST -Credential $credential -skiphttpErrorcheck } catch { #Write-Warning $Error[0] Write-Log -level ERROR -Message "$error[0].InvocationInfo.line" write-log -Level ERROR -Message "Errorcode 200.2" Write-host "200.2" exit } # Get statuscode 200=OK 500 $StatusCode = $PostRequestNewConference.StatusCode # Write to log write-log -Level INFO -Message "ClientSessionID OK (200=OK 500=Expired: $statuscode" # Read response and if Statuscode is 500 catch new ClientSessionID [xml]$ConferenceResult = $PostRequestNewConference # If error 500, extract new ClientSessionID and run the post one more time if ($statuscode -eq '500') { [xml]$ConferenceResult = $PostRequestNewConference $newClientSessionID = $ConferenceResult.Envelope.Body.Fault.detail.clientsessionid.'#text' Write-Log -Level INFO -Message "New ClientSessionID $newClientSessionID " # XML file used to post for booking of conference [System.Xml.XmlDocument] $PostConferenceResult = @" <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <ContextHeader xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <SendConfirmationMail>$SendConfirmationMail</SendConfirmationMail> <ExcludeConferenceInformation>$ExcludeConferenceInformation</ExcludeConferenceInformation> <ClientLanguage>$ClientLanguage</ClientLanguage> </ContextHeader> <ExternalAPIVersionSoapHeader xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <ClientVersionIn>$ClientVersionIn</ClientVersionIn> <ClientIdentifierIn>$ClientIdentifierIn</ClientIdentifierIn> <ClientLatestNamespaceIn>$ClientLatestNamespaceIn</ClientLatestNamespaceIn> <NewServiceURL>$NewServiceURL</NewServiceURL> <ClientSession>$newClientSessionID</ClientSession> </ExternalAPIVersionSoapHeader> </soap12:Header> <soap12:Body> <SaveConference xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <Conference> <ConferenceID>$conferenceid</ConferenceID> <Title>$title</Title> <StartTimeUTC>$starttimeUTC</StartTimeUTC> <EndTimeUTC>$endtimeUTC</EndTimeUTC> <OwnerId>$ownerID</OwnerId> <OwnerUserName>$OwnerUserName</OwnerUserName> <OwnerFirstName>$OwnerFirstName</OwnerFirstName> <OwnerLastName>$OwnerLastName</OwnerLastName> <OwnerEmailAddress>$OwnerEmailAddress</OwnerEmailAddress> <ConferenceType>$ConferenceType</ConferenceType> <Bandwidth>$Bandwidth</Bandwidth> <PictureMode>$PictureMode</PictureMode> <Encrypted>$Encrypted</Encrypted> <DataConference>$DataConference</DataConference> <ShowExtendOption>$ShowExtendOption</ShowExtendOption> <Password>$Password</Password> <BillingCode>$billingcode</BillingCode> <ISDNRestrict>$ISDNRestrict</ISDNRestrict> <Participants> <Participant> <NameOrNumber>$NameOrNumber</NameOrNumber> <ParticipantCallType>$ParticipantCallType</ParticipantCallType> </Participant> </Participants> </Conference> </SaveConference> </soap12:Body> </soap12:Envelope> "@ # POST a new request for an Conference try { $PostRequestNewConference = Invoke-WebRequest -Uri $config.ConfigTMs.pathCiscoTMSAPI -Body $PostConferenceResult -ContentType 'text/xml' -Method POST -Credential $credential -skiphttpErrorcheck } catch { #Write-Warning $Error[0] Write-Log -level ERROR -Message "$error[0].InvocationInfo.line" write-log -Level ERROR -Message "Errorcode 200.3" Write-host "200.3" exit } # Catch the conference values after rerun of invoke-webrequest because of error 500 [xml]$ConferenceResult = $PostRequestNewConference $TMSConferenceID = $ConferenceResult.Envelope.Body.SaveConferenceResponse.SaveConferenceResult.ConferenceId } $TMSConferenceID = $ConferenceResult.Envelope.Body.SaveConferenceResponse.SaveConferenceResult.ConferenceId # ConferenceID in Cisco TMS Write-Log -Level INFO -Message "TMSConferenceID $TMSConferenceID " ################################################################################################ ################################################################################################ # This section if for extracting the number to call to the conference ################################################################################################ ################################################################################################ # XML file to post for more info about the conference to extract the number to call for the Conference. [System.Xml.XmlDocument] $XMLConferenceByID = @" <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <ContextHeader xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <SendConfirmationMail>$SendConfirmationMail</SendConfirmationMail> <ExcludeConferenceInformation>$ExcludeConferenceInformation</ExcludeConferenceInformation> <ClientLanguage>$ClientLanguage</ClientLanguage> </ContextHeader> <ExternalAPIVersionSoapHeader xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <ClientVersionIn>$ClientVersionIn</ClientVersionIn> <ClientIdentifierIn>$ClientIdentifierIn</ClientIdentifierIn> <ClientLatestNamespaceIn>$ClientLatestNamespaceIn</ClientLatestNamespaceIn> <NewServiceURL>$NewServiceURL</NewServiceURL> <ClientSession>string</ClientSession> </ExternalAPIVersionSoapHeader> </soap12:Header> <soap12:Body> <GetConferenceById xmlns="http://tandberg.net/2004/02/tms/external/booking/"> <ConferenceId>$TMSConferenceID</ConferenceId> </GetConferenceById> </soap12:Body> </soap12:Envelope> "@ # POST a new request for an Conference try { $PostRequestConferenceByID = Invoke-WebRequest -Uri $config.ConfigTMs.pathCiscoTMSAPI -Body $XMLConferenceByID -ContentType 'text/xml' -Method POST -Credential $credential -skiphttpErrorcheck } catch { #Write-Warning $Error[0] Write-Log -level ERROR -Message "$error[0].InvocationInfo.line" write-log -Level ERROR -Message "Errorcode 200.4" Write-host "200.4" exit } # Send the field RawContent to file $PostRequestConferenceByID.RawContent | Out-File "$Tempfolder\$TMSConferenceID.xml" # Read variable in Configfile to which row in file to extract $RowInFile = $config.ConfigTMS.RowInFile # Extract the row with the number to a variable $callinnumber = Get-Content "$Tempfolder\$TMSConferenceID.xml" | Select-Object -Index $RowInFile # Extract the number $CallinnumberFinal = $callinnumber -replace "\D+" write-log -Level INFO -Message "ConferenceCallInNumber: $callinnumberFinal" Remove-Item "$Tempfolder\$TMSConferenceID.xml" ################################################################################################ # # Create the Email to send to the requester. # ################################################################################################ # Variabelkonverting för att kunna infoga värden i htmlformat. $emailsubject = $config.configtms.EmailSubject # The number to dail in $ConferenceNumber = $CallinnumberFinal # Pin-code to the meeting $PinCode = $ConferenceResult.Envelope.Body.SaveConferenceResponse.SaveConferenceResult.Password write-log -Level INFO -Message "Password for meeting: $pincode" write-log -Level INFO -Message "Email to requester: $bookedby" write-log -Level INFO -Message "Referencenumber: $billingcode" # Phonenumber for national participants $PhoneNumber = $config.configtms.Phonenumber # Phonenumber for international participants $PhoneNumberINT = $config.configtms.PhonenumberINT #$NumbersOfPaticipants = $ExtDeltagare.count $domain=$config.configtms.Domain $JoinUrl=$config.configtms.JoinUrl # Email params $EmailParams = @{ To = $BookedBy From = $config.ConfigTMS.EmailFrom Smtpserver = $config.ConfigTMS.EmailSMTP Subject = "$emailsubject $BookingNumber | $(Get-Date -Format dd-MMM-yyyy)" } # Create html header whit stylesheet $html = @" <!DOCTYPE html> <html> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"> <body> <style> body { background-color: Gainsboro; } h4 { background-color:Tomato; color:white; text-align: center; } p { font-size: 13px; } ul { font-size: 13px; } </style> "@ # Create html header whit stylesheet $html = @" <!DOCTYPE html> <html> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"> <body> <style> body { background-color: Gainsboro; } h4 { background-color:Tomato; color:white; text-align: center; } p { font-size: 13px; } ul { font-size: 13px; } </style> "@ # Set html $html = $html + @" <table cellpadding="10" cellspacing="10"> <tr> <td> <h4>BRYGGBOKNING:<b>$BookingNumber</b></h4> <p><b>Hej!</b></p> <p>Här kommer din videokonferensebokning.</p> <p>Kontrollera gärna att tidpunkt och datum stämmer.</p> <p>Observera att mötesrummet nedan endast finns tillgängligt för den tiden som ni har bokat. Var vänliga och kontakta Tekniksupporten om ni behöver ändra något.</p> <p><b><u>Samtliga deltagare ska ringa</u></b> in till bryggans mötesrum. Om ytterligare deltagare behöver vara med via telefon eller videokonferens under tiden som ni är i bryggan, behöver även de ringa in till bryggans mötesrum.</p> <p>All info om hur man ringer och vad man bör tänka på vid t ex. skyddad deltagare, står nedan.På <a href="https://intranatet.dom.se/stod-och-verktyg/it-teknik-och-telefoni/videokonferens/webrtc/">intranätet</a> finns information och lathundar (på svenska och engelska) om WebRTC som ni gärna får bifoga till deltagarna.</p> <p>Se till att alla får informationen om hur de ska ringa in. Det är alltså <u><b>upp till er att förmedla informationen vidare till berörda parter</b></u> så att de vet hur de ska ringa.</p> <p>Det finns instruktioner på engelska längst ner.</p> <p>Då det finns en begränsad mängd platser i videokonferensbryggan var vänlig och kontakta Tekniksupporten <a href="mailto:teknik@dom.se">teknik@dom.se</a> om ni inte längre behöver bokningen eller vill justera bokningen.</p> <p>Vid problem kontaktar personal inom Sveriges Domstolar Tekniksupporten. Externa parter kontaktar först sin videokonferensansvarig för att säkerställa att problemet inte hos dem, därefter kontaktar parten domstolen.</p> <p>Med Vänlig Hälsning<br> Tekniksupporten</p> <p>Tfn: 22 000, tonval 3</p> <hr style="height:2px" color="black"> <h4>Du har bokat in följande virtuella mötesrum i Sveriges Domstolars brygga:</h4> <p>Ärendenummer:<b>$BookingNumber</b></p> <p>Datum och tid:$starttimeToMail - $endtimeToMailformat</p> <p>(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</p> <p><i>Mötesrummet öppnar 5 minuter innan bokad tid.</i></p> <hr style="height:2px" color="black"> <p>Mötesnummer:<b>$ConferenceNumber</b><br> Pin-kod:<b>$PinCode</b><br> <hr style="height:2px" color="black"> <h4>Instruktioner</h4> <table style="color:red"> <tr> <h5>Vid skyddad deltagare</h5> <ul> <li>Tänk på att inte berätta eller visa var denne sitter i videokonferenssamtalet.</li> <li>Du måste även förmedla till organisationen där den skyddade parten sitter att det är en skyddad part och att även de måste vara försiktiga med vad de säger och visar i videokonferenssamtalet.</li> <li>Man måste även vara generellt försiktig med hur man lämnar ut information om målet och var den skyddade parten eventuellt sitter.</li> </ul> </tr> </table> <p><U><b>Sveriges Domstolar: Videokonferens och JabberVideo-användare</b></u><br> <ul> <li>Ring:<b>$ConferenceNumber</b> <li>PIN-kod från Sal: Välj "Sänd tonval" i pekskärmen. Skicka PIN-kod:<b>$PinCode#</b></li> <li>PIN-kod från Rum: Aktivera tonval med knapp # på fjärrkontrollen. Skicka PIN-kod:<b>$PinCode#</b></li> <li>PIN-kod från JabberVideo/Movi: Välj "Tonval". Skicka PIN-kod:<b>$PinCode#</b></li> </ul> </p> <p><u><B>Deltagare via Internet/SGSI (utanför Sveriges Domstolar)</b></u><br> <ul> <li>Ring:<b><a href=mailto:"$ConferenceNumber@$domain">$ConferenceNumber@$domain</a></b></li> <li>Med tonval/knappsats slå PIN-kod:<b>$PinCode#</b></li> </ul> </p> <p><u><b>Telefondeltagare och Videokonferens via ISDN (utanför Sveriges Domstolar)</b></u><br> <ul> <li>Ring:<b>$PhoneNumber</b></li> <li>Med tonval/knappsats slå mötesnummer:<b>$ConferenceNumber#</b></li> <li>Med tonval/knappsats slå PIN-kod:<b>$PinCode#</b></li> </ul> <hr style="height:2px" color="black"> <p><B>Booking confirmation: Virtual meeting room in the Swedish Courts MCU</b></p> <p><b><u>Participant via Internet/SGSI (outside the Swedish National Courts)</u></b></p> <ul> <li>Call:<b><a href=mailto:"$ConferenceNumber@$domain">$ConferenceNumber@$domain</a></b></li> <li>Send Pin:<b>$PinCode#</b></li> </ul> </p> <p><u><b>Participant via web browser - WebRTC (outside the Swedish National Courts)</u></b><br></p> <ul> <li>Join using web browser (not Internet Explorer or Edge version 41):</li> <b><a href="$joinurl">$joinurl</a></b> <li>Meeting number:<b>$ConferenceNumber</b></li> <li>PIN:<b>$PinCode</b></li> </ul> <p><u><b>Participant by phone or Video via ISDN (outside the Swedish National Courts)</b></u><br> <ul> <li>Call ISDN to:<b>$PhoneNumberINT</b></li> <li>Send meeting number:<b>$ConferenceNumber#</b></li> <li>Send Pin:<b>$PinCode#</b></li> </ul> </td> </tr> </table> "@ # Close html document $html = $html + @" </body> </html> "@ # Send mail with info about the conference to "bookedby" try { Send-MailMessage @EmailParams -Body $html -BodyAsHtml -Encoding utf8 } catch { #Write-Warning $Error[0] Write-Log -level ERROR -Message "$error[0].InvocationInfo.line" write-log -Level ERROR -Message "Errorcode 300" Write-host "300" exit } write-log -Level INFO -Message "################################################################################################" |