none
SIP ID provisioning RRS feed

  • Question

  • Dear All,

    I am using following powershell script for Lync provisioning. but provisioning is not happening. getting the following error.

    please help.

    ===================================

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.   at System.ThrowHelper.ThrowKeyNotFoundException()   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)   at Microsoft.ResourceManagement.Query.QueryParametersGenerator.WriteRequestedAttributes()   at Microsoft.ResourceManagement.Query.QueryParametersGenerator.BuildParameterString()   at Microsoft.ResourceManagement.Query.QueryProcessor.BuildSqlCommand(Query objectRepresentation, Boolean countResultsOnly)   at Microsoft.ResourceManagement.Query.QueryProcessor.ExecuteQuery(Query query, Nullable`1 maximumTime, Boolean& endOfSequence, Boolean countResultsOnly, Int64& resultCount, Int64& executionTime)   at Microsoft.ResourceManagement.Data.DataAccess.GetObject(Guid objectId, CultureInfo locale, Guid requestor, String[] attributeNames, Boolean includeInlineRights)   at Microsoft.ResourceManagement.Data.DataAccess.GetObject(Guid objectId, String[] attributeNames)   at Microsoft.ResourceManagement.ActionProcessor.ActionDispatcher.Read(Guid objectId, CultureInfo locale, Nullable`1 requestor, Nullable`1 resourceTime, String[] requestedAttributes, Boolean includeRights)   at Microsoft.ResourceManagement.ActionProcessor.ActionDispatcher.ProcessOutputRequest(RequestType request)   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteGetAction(RequestType request)   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction(RequestType request)   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.ExecuteAction[ResponseBodyType](RequestType request)   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request, Guid requestIdentifier, Object redispatchSingleInstanceKey, Boolean isRedispatch)   at Microsoft.ResourceManagement.WebServices.RequestDispatcher.DispatchRequest[ResponseBodyType](RequestType request)   at Microsoft.ResourceManagement.Workflow.Hosting.RequestWorkItemProcessor.DispatchRequest[TResponseType](RequestType request, Boolean applyAuthorizationPolicy)   at Microsoft.ResourceManagement.Workflow.Hosting.RequestWorkItemProcessor.ProcessGetWorkItem(ReadRequestWorkItem readWorkItem)   at Microsoft.ResourceManagement.Workflow.Hosting.RequestWorkItemProcessor.ProcessWorkItem(WorkItem workItem)

    ====================================

    Add-PSSnapin FimAutomation
    Import-Module SkypeforBusiness
    Enable-CsUser –Identity $UserName –RegistrarPool lync.shashicloud.in –SipAddressType $EmailAddress
    $tempSIP = “sip:$EmailAddress”
    $ImportState = [Microsoft.ResourceManagement.Automation.ObjectModel.ImportState]
    $importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
    $importObject.ObjectType = “Person”
    $importObject.TargetObjectIdentifier = $objID
    $importObject.SourceObjectIdentifier = $objID
    $importObject.State = $ImportState::Put
    $importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange
    $importChange.Operation = 1
    $importChange.AttributeName = “SIPaddress”
    $importChange.AttributeValue = $tempSIP
    $importChange.FullyResolved = 1
    $importChange.Locale = “Invariant”
    if ($importObject.Changes -eq $null) {$importObject.Changes = (,$importChange)}
    Import-FIMConfig -Uri “http://mimservice.shashicloud.in:5725” -ImportObject $importObject



    Monday, February 5, 2018 11:10 AM

Answers

  • We have used following MIMWAL workflow for SFB User Account provisioning

    ------------------------------------------------------------------------------------------------

    param
    (
           [parameter(mandatory = $true)] $AccountName
           ,[parameter(mandatory = $true)] $EmailAddress
    )

    function InvokeImmediateTermination
    {
        $stdOutFile = Join-Path $env:TEMP -ChildPath "StdOut_$AECRequestId.log"
        $stdErrFile = Join-Path $env:TEMP -ChildPath "StdErr_$AECRequestId.log"

        $command = @"
        & {
            if (!(Get-Module -Name "SkypeforBusiness"))
            {
                Import-Module SkypeforBusiness
            }

            Enable-CsUser -Identity "$AccountName" -RegistrarPool "lync.shashicloud.in" -SipAddress "sip:$EmailAddress"

            if (`$Error.Count -eq 0)
            {
                "!!Success!!"
            }
            else
            {
                # Can't easily use stdErrFile as it comes as CLIXML and includes Warning/Verbose/Debug streams as well. So we'll simply use stdOutFile
                `$Error
            }
        }
    "@

        Write-Debug $command

        $commandBytes = [System.Text.Encoding]::Unicode.GetBytes($command)
        $encodedCommand = [Convert]::ToBase64String($commandBytes)

        Start-Process 'PowerShell.exe' `
            -ArgumentList "-Version 3.0 -NonInteractive -OutputFormat Text -EncodedCommand $encodedCommand" `
            -RedirectStandardOutput $stdOutFile `
            -RedirectStandardError $stdErrFile `
            -Wait

        $statusLine = Get-Content $stdOutFile| Select-Object -Last 2 | ? {
            $_.Contains("!!Success!!")
        }
           
        if ([string]::IsNullOrEmpty($statusLine))
        {
            throw $((Get-Content $stdOutFile) -join "`r`n")
        }
        else
        {
            Write-Debug "Script executed successfully."
        }

        Remove-Item $stdOutFile -Force
        Remove-Item $stdErrFile -Force
    }

    InvokeImmediateTermination


    Monday, March 12, 2018 10:03 AM

All replies

  • I also replaced codes with following codes.

    Param($AN)
    Import-Module SkypeforBusiness
    Enable-CsUser –Identity $AN –RegistrarPool lync.shashicloud.in –SipAddressType EmailAddress

    Monday, February 5, 2018 11:20 AM
  • We have used following MIMWAL workflow for SFB User Account provisioning

    ------------------------------------------------------------------------------------------------

    param
    (
           [parameter(mandatory = $true)] $AccountName
           ,[parameter(mandatory = $true)] $EmailAddress
    )

    function InvokeImmediateTermination
    {
        $stdOutFile = Join-Path $env:TEMP -ChildPath "StdOut_$AECRequestId.log"
        $stdErrFile = Join-Path $env:TEMP -ChildPath "StdErr_$AECRequestId.log"

        $command = @"
        & {
            if (!(Get-Module -Name "SkypeforBusiness"))
            {
                Import-Module SkypeforBusiness
            }

            Enable-CsUser -Identity "$AccountName" -RegistrarPool "lync.shashicloud.in" -SipAddress "sip:$EmailAddress"

            if (`$Error.Count -eq 0)
            {
                "!!Success!!"
            }
            else
            {
                # Can't easily use stdErrFile as it comes as CLIXML and includes Warning/Verbose/Debug streams as well. So we'll simply use stdOutFile
                `$Error
            }
        }
    "@

        Write-Debug $command

        $commandBytes = [System.Text.Encoding]::Unicode.GetBytes($command)
        $encodedCommand = [Convert]::ToBase64String($commandBytes)

        Start-Process 'PowerShell.exe' `
            -ArgumentList "-Version 3.0 -NonInteractive -OutputFormat Text -EncodedCommand $encodedCommand" `
            -RedirectStandardOutput $stdOutFile `
            -RedirectStandardError $stdErrFile `
            -Wait

        $statusLine = Get-Content $stdOutFile| Select-Object -Last 2 | ? {
            $_.Contains("!!Success!!")
        }
           
        if ([string]::IsNullOrEmpty($statusLine))
        {
            throw $((Get-Content $stdOutFile) -join "`r`n")
        }
        else
        {
            Write-Debug "Script executed successfully."
        }

        Remove-Item $stdOutFile -Force
        Remove-Item $stdErrFile -Force
    }

    InvokeImmediateTermination


    Monday, March 12, 2018 10:03 AM
  • I'm not sure I understand the follow-on posts, but, usually that error means you have an object type or attribute name spelled or cased incorrectly. They are case-sensitive.

    Thanks,
    Brian

    Consulting | Blog | AD Book

    Monday, March 12, 2018 11:42 PM
    Moderator