Skype for Business shell commands from code

0


I've developed an application that manages Skype For Business users configurations.
One of the operations I need to run should set Skype user's registrar pool, using this command:

Move-CsUser -Identity [UserName] -Target [RegistrarPool] -Confirm:$false

Now when I run the command from the command line – it works great.
But, unlike the other Skype shell commands I use within my application, when I run that command using my c# code I get this terrible error:

Move-CsUser : Unable to cast COM object of type 'System.__ComObject' to interface type \r\n
'Microsoft.Rtc.Interop.User.ICsUserManagement'. This operation failed because the QueryInterface call on the COM \r\n
component for the interface with IID '{D5ADD966-BDC3-4A8F-BFE8-6A59A9F74CB2}' failed due to the following error: Class \r\n
not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).\r\nAt line:1 char:1\r\n+
Move-CsUser -Identity 'testuser' -Target 'XXX' -Confirm: ...\r\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r\n    +
CategoryInfo          : InvalidOperation: (CN=Agent Develo...DC=il,DC=tleumi:OCSADUser) [Move-CsUser], InvalidCa \r\n   stException\r\n   
+ FullyQualifiedErrorId : MoveError,Microsoft.Rtc.Management.AD.Cmdlets.MoveOcsUserCmdlet\r\n \r\n"

I'm apparently terrible at overcoming COM object's errors, despite my best attempts to solve it.

Can anyone give me a hand?
How can I make it work?

c#
com-interop
skype-for-business
comobject
com-object
asked on Stack Overflow Dec 3, 2017 by Tali B.

1 Answer

0

yeah its a pain have this every time I do a lync coding project. Right click on your project name go to properties. you need to set the platform target to x64 not any cpu

answered on Stack Overflow Dec 5, 2017 by Mark W.

User contributions licensed under CC BY-SA 3.0