|
- WorkwithLync.ps1
# workwithLync.ps1 / rb / 2021
#adde oder entferne einen Benutzer an Lync
# erforderliche Provisioning-Parameter der Resource:
# $username # wird immer von Tenfold mitgeliefert
# $cred # konfigurierte Zugangsdaten für den Exchangeserver
# $connectionUri # z.B. "https://myexchangesrv/PowerShell"
# $SipDomain # Name der Domäne
# $Cnfp # Name der ConferencingPolicy
# $RegPool # Name des Registrarpools
# erforderliche Resourcenbedingungen:
# "Resource - New"
# "Resource - Delete"
##############################################################
$username = $params.request.person.masterdata.userName
$connectionUri = $params.connectionuri
$SipDomain = $params.sipDomain
$Cnfp = $params.Cnfp
$RegPool = $params.Regpool
#Set-ExecutionPolicy -Scope CurrentUser unrestricted
#####Remoteverbindung zum Lync herstellen
$sessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$admsession = New-Pssession -Connectionuri $connectionUri -credential $cred -sessionoption $sessionOption
if ($admsession.State -ne 'Opened')
{
throw "error: new-pssession on $connectionUri failed"
}
else
{
#Write-Host "Verbindung hergestellt"
Import-PSSession $admsession -DisableNameChecking -AllowClobber -CommandName GetCSService,Get-CSUser,Get-CSADUser,Enable-CSUser,Disable-CSUser,Grant-CSConferencingPolicy # | Out-Null
$ret = get-CSUser $username -ErrorAction SilentlyContinue
if ( $ret)
{ #echo "user will be disabled"
Disable-CsUser -Identity $username -Confirm:$false
}
else {
#echo "lyncuser will be enabled"
$usr = Get-CSADUser $username # -Property FirstName,LastName,WindowsEmailAddress
$usrVorname = $usr.FirstName
$usrNachname = $usr.LastName
$usrmail = $usr.WindowsEmailAddress
#echo "sip:$usrmail"
Enable-CSUser -identity $username -RegistrarPool $RegPool -SipDomain $SipDomain -SipAddress "sip:$usrmail" -confirm:$false
Grant-CSConferencingPolicy $username -Policy $Cnfp
}
}
Remove-PSSession $admsession
|
|