0 votes

I try to establish a custom command for MS Teams call forwarding. I have created a paramter for the calltarget. But it looks like it has not the right format <br>
. . Set-CsUserCallingSettings -Identity %userPrincipalName% -IsForwardingEnabled $true -ForwardingType immediate -ForwardingTargetType singletarget -ForwardingTarget %param-deputycall%<br>
. .image.png .<br>
Error message: Cannot process argument transformation on parameter 'ForwardingTarget'. Cannot convert value to type System.String. Stack trace: at <ScriptBlock>, <No file>: line 28

How do I modify the paramater? Thanks.

by (470 points)
edited by

1 Answer

0 votes
by (272k points)

Hello Boris,

First of all, all value references in all Adaxes scripts must be wrapped into double quotes. Otherwise, the script can be incorrectly recognized by PowerShell after resolving value references. Also, your parameter is of Directory object picker type. It means that the value reference for the parameter will resolve into a distinguished name (DN) which is unacceptable for the -ForwardingTarget parameter of the Set-CsUserCallingSettings cmdlet. To achieve the desired, you need to have something like below in your script. In the code sample, the $propertyName variable specifies the schema name of a property. The property value will be taken from the account specified in the custom command parameter and passed to the cmdlet parameter.

$propertyName = "mobile" # TODO: modify me

# Get property value
$parameterObject = $Context.BindToObjectByDN("%param-deputycall%")
try
{
    $value = $parameterObject.Get($propertyName)
}
catch
{
    $Context.LogMessage("Property $propertyName is not specified for the forwarding target.", "Warning")
    return
}

Set-CsUserCallingSettings -Identity "%userPrincipalName%" -IsForwardingEnabled $true -ForwardingType immediate -ForwardingTargetType singletarget -ForwardingTarget $value
0

Thanks, for your help. Works perfectly

Related questions

0 votes
1 answer

Is it possible to add multiple members to a group in a singe call to the REST API? The example code only shows a single member. What would the data structure look like in that case?

asked Dec 13, 2021 by swengr59 (60 points)
0 votes
1 answer

Is it possible to call execution of Adaxes custom command via SPML?

asked Oct 16, 2019 by Dmytro.Rudyi (920 points)
0 votes
1 answer

I'm currently running a SQL SPROC from within powershell, getting a value, and attempting to assign that value to an AD attribute. Everything goes fine getting the value, but ... avoid calling PS from within PS to load the module and run the command. Thanks!

asked Feb 3, 2017 by gmadd13 (50 points)
0 votes
0 answers

I am trying to create an on call schedule within Adaxes. We have 3 people who rotate through an on call schedule for a week with a backup. I would like to send a text to the ... 456-0123 2 - John Smith 666-789-4567 3 - Bob Jones 777-123-6789 Thanks in advance!

asked Apr 29, 2015 by felt1977 (120 points)
0 votes
1 answer

Hi, Can I use a PS script to call Adaxes with a list of users or computer and run through it? For example, PS script checks for users NotLoggedOnFor 30 days and sends this list to Adaxes to disable accounts.

asked Sep 6, 2011 by minhe (60 points)
3,351 questions
3,052 answers
7,791 comments
545,106 users