Powershell - Bulk Import from a csv file Set user DID

New Contributor

Hello,

 

I want to make a script where i can import a .csv file with multiple users and numbers.

 

The original script is= 

 

 

 Set-CsUser -ID a.user@domain.com -OnPremLineURI tel:+31881234567 -EnterpriseVoiceEnabled $true -HostedVoiceMail $true

 

 

 

I tried to make a script, but it fails on: 

 

 

Cannot bind parameter 'Identity'. Cannot convert value "System.Collections.Hashtable" to type "Microsoft.Rtc.Management.AD.UserIdParameter". Error: "Cannot convert hashtable to an object of the following type: Microsoft.Rtc.Management.AD.UserIdParameter. Ha
shtable-to-Object conversion is not supported in restricted language mode or a Data section."

 

 

 

The Script i tried to use is (I find one online and edit the script):

 

 

Import-Csv C:\path\file.csv -Delimiter ';'
    ForEach-Object{
        $paramsetcsuser = @{
            Identity = $_.identity
            EnterpriseVoiceEnabled = if($_.EnterpriseVoiceEnabled -eq 'true'){$true}else{$false}
            HostedVoiceMail = if($_.HostedVoiceMail -eq 'true'){$true}else{$false}
            OnPremLineURI = 'tel:' + $_.OnPremLineURI
            UnknownParameter5 = '+'
            UnknownParameter6 = $_.OnPremLineURI
        }
Set-CsUser $paramsetcsuser
}

    

 

 

 

csv file i use:

Vincent_Holthuizen_0-1627481362964.png

 

 

Is there anyone that can help me with this?

 

2 Replies
What powershell module are you using?

@adam deltinger 

Iam using the MicrosoftTeams module

 

Set-ExecutionPolicy unrestricted
Install-Module MicrosoftTeams -Force

 

Import-Module -Name MicrosoftTeams
 
#Connect to Microsoft Teams
Connect-MicrosoftTeams