Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object System.Windows.Forms.Form $form.Text = 'Teams Nummer anlegen' $form.Size = New-Object System.Drawing.Size(400,250) $form.StartPosition = 'CenterScreen' $okButton = New-Object System.Windows.Forms.Button $okButton.Location = New-Object System.Drawing.Point(75,180) $okButton.Size = New-Object System.Drawing.Size(75,23) $okButton.Text = 'OK' $okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK $form.AcceptButton = $okButton $form.Controls.Add($okButton) $cancelButton = New-Object System.Windows.Forms.Button $cancelButton.Location = New-Object System.Drawing.Point(150,180) $cancelButton.Size = New-Object System.Drawing.Size(75,23) $cancelButton.Text = 'Abbrechen' $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $form.CancelButton = $cancelButton $form.Controls.Add($cancelButton) $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,20) $label.Size = New-Object System.Drawing.Size(280,20) $label.Text = 'Bitte den Benutzernamen eingeben:' $form.Controls.Add($label) $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,70) $label.Size = New-Object System.Drawing.Size(280,20) $label.Text = 'Bitte Telefonnumer eingeben (inkl. +43):' $form.Controls.Add($label) $textBox = New-Object System.Windows.Forms.TextBox $textBox.Location = New-Object System.Drawing.Point(10,40) $textBox.Size = New-Object System.Drawing.Size(260,20) $form.Controls.Add($textBox) $textBox1 = New-Object System.Windows.Forms.TextBox $textBox1.Location = New-Object System.Drawing.Point(10,100) $textBox1.Size = New-Object System.Drawing.Size(260,20) $form.Controls.Add($textBox1) $form.Topmost = $true $form.Add_Shown({$textBox.Select()}) $result = $form.ShowDialog() if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $x = $textBox.Text $x $form.Add_Shown({$textBox1.Select()}) $y = $textBox1.Text $y } #Eingegebener Person Variable x die Rufnummer Variable Y zuweisen Set-CsPhoneNumberAssignment -Identity "$x" -PhoneNumber "$y" -PhoneNumberType DirectRouting #Zuweisung der Routing Policy MRS Grant-CSOnlineVoiceRoutingPolicy -Identity "$x" -PolicyName MRS #Sleep Timer, damit später die richtige Route angezeigt wird Function Sleep-Progress($seconds) { $s = 0; Do { $p = [math]::Round(100 - (($seconds - $s) / $seconds * 100)); Write-Progress -Activity "Waiting..." -Status "$p% Complete:" -SecondsRemaining ($seconds - $s) -PercentComplete $p; [System.Threading.Thread]::Sleep(1000) $s++; } While($s -lt $seconds); } Sleep-Progress 30 #Ausgabe des Users Get-CsOnlineUser -filter "LineURI -eq 'tel:$y'" | select displayName, enter*, LineURI, voi*, userprinc*, onlinevoice*, enab*