Script Repository


Assign Conferencing Policy in Skype for Business Online

June 06, 2017
3216

The script assigns a Conferencing Policy to a user in Skype for Business Online.

Skype for Business Online Connector Module is required to communicate with Skype for Business Online. Download and install it on the computer where your Adaxes service runs.

Parameter:

  • $policyName - specifies the name of the Conferencing Policy to assign.
Edit Remove
PowerShell
$policyName = "Tag:BposSAllModalityNoRecNoVideo" # TODO: uncomment the policy you need
# $policyName = "Tag:BposSAllModality"
# $policyName = "Tag:BposSAllModalityNoVideo"
# $policyName = "Tag:BposSAllModalityMinVideoBW"
# $policyName = "Tag:BposSAllModalityNoDialout"
# $policyName = "Tag:BposSAllModalityNoDialoutNoVideo"
# $policyName = "Tag:BposSAllModalityNoDialoutMinVideoBW"
# $policyName = "Tag:BposSAllModalityNoFT"
# $policyName = "Tag:BposSAllModalityNoFTNoVideo"
# $policyName = "Tag:BposSAllModalityNoFTMinVideoBW"
# $policyName = "Tag:BposSAllModalityNoFTNoDialout"
# $policyName = "Tag:BposSAllModalityNoFTNoDialoutNoVideo"
# $policyName = "Tag:BposSAllModalityNoFTNoDialoutMinVideoBW"
# $policyName = "Tag:BposSAllModalityNoRec"
# $policyName = "Tag:BposSAllModalityNoRecMinVideoBW"
# $policyName = "Tag:BposSAllModalityNoRecNoDialout"
# $policyName = "Tag:BposSAllModalityNoRecNoDialoutNoVideo"
# $policyName = "Tag:BposSAllModalityNoRecNoDialoutMinVideoBW"
# $policyName = "Tag:BposSDataProtection"
# $policyName = "Tag:BposSDataProtectionNoVideo"
# $policyName = "Tag:BposSDataProtectionMinVideoBW"
# $policyName = "Tag:BposSDataProtectionNoDialout"
# $policyName = "Tag:BposSDataProtectionNoDialoutNoVideo"
# $policyName = "Tag:BposSDataProtectionNoDialoutMinVideoBW"
# $policyName = "Tag:BposSIMPOnly"
# $policyName = "Tag:BposSIMPOnlyNoDialout"
# $policyName = "Tag:BposSIMPOnlyNoRec"
# $policyName = "Tag:BposSIMPOnlyNoRecNoDialout"
# $policyName = "Tag:BposSVoipDisabled"
# $policyName = "Tag:BposSVoipDisabledNoDialout"
# $policyName = "Tag:BposSVoipDisabledNoRec"
# $policyName = "Tag:BposSVoipDisabledNoRecNoDialout"
# $policyName = "Tag:BposSAllModalityWithPPANoFT"
# $policyName = "Tag:BposSVoipDisabledWithPPANoFT"

# Get the user ID in Office 365
try
{
    $objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
    $Context.LogMessage("The user doesn't have an Office 365 Account", "Warning")
    return
}

# Script block to assign a Conferencing Policy to a user
$scriptBlock = {
    Import-Module LyncOnlineConnector

    # Connection to Office365
    $password = ConvertTo-SecureString -AsPlainText -Force -String $password
    $credential = New-Object System.Management.Automation.PsCredential($adminName,$password)
    
    try
    {
        # Connect to Skype for Business Online
        $session = New-CsOnlineSession -Credential $credential
        Import-PSSession $session -AllowClobber | Out-Null
        
        # Assign the policy
        Grant-CsConferencingPolicy $objectId -PolicyName $policyName
    }
    finally
    {
        # Close the remote session and release resources
        Remove-PSSession $session
    }
}

# Get credential to connect to Office 365 with
$office365Cred = $Context.GetOffice365Credential()
$adminName = $office365Cred.Username
$password = $office365Cred.GetNetworkCredential().Password

# Start Windows PowerShell as a separate process and run the script block in that process
$powershellPath = "$env:windir\system32\windowspowershell\v1.0\powershell.exe"
$arguments = @("-noninteractive", "-noprofile", "-executionpolicy bypass", "-Command `$adminName = '$adminName'; `$password = '$password'; `$objectId = '$objectId'; `$policyName = '$policyName'; $scriptBlock")
$starProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$starProcessInfo.FileName = $powershellPath
$starProcessInfo.Arguments = $arguments
$starProcessInfo.WindowStyle = "Hidden"
$starProcessInfo.CreateNoWindow = $True
$starProcessInfo.UseShellExecute = $False
$starProcessInfo.RedirectStandardOutput = $True 
$starProcessInfo.RedirectStandardError = $True
$process = [System.Diagnostics.Process]::Start($starProcessInfo)
$resultErrors = $process.StandardError.ReadToEnd()
$resultOutput = $process.StandardOutput.ReadToEnd()

# Add operation result to the Execution Log
# Add errors
if (-not([System.String]::IsNullOrEmpty($resultErrors)))
{
    $Context.LogMessage($resultErrors, "Error")
}

# Add information messages and warnings
if (-not([System.String]::IsNullOrEmpty($resultOutput)))
{
    $Context.LogMessage($resultOutput, "Warning")
}
See Also: Assign Conferencing Policy in Skype for Business On-Premises.

Comments ( 0 )
No results found.
Leave a comment

Related Scripts