Auteur de questions
Using powershell cmdlet with Lync

-
Hi Team,
I am trying to run a few commands like Get-CsServerVersion and Test-CsDatabase -LocalService using the following code :
Runspace runSpace = RunspaceFactory.CreateRunspace(); runSpace.Open(); Pipeline pipeLine = runSpace.CreatePipeline(); //string script = Get-Process; string script = "Get-CsServerVersion"; pipeLine.Commands.AddScript(@"Import-Module 'C:\Program Files\Common Files\\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1'"); pipeLine.Commands.AddScript(script); pipeLine.Commands.Add("Out-String"); Collection<PSObject> results = pipeLine.Invoke(); StringBuilder stringBuilder = new StringBuilder(); foreach (PSObject obj in results) { stringBuilder.AppendLine(obj.ToString()); }
But the error i get is :
"The term 'Get-CsServerVersion' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
Can you please help me resolve this .
Thanks and Regards.
Question
Toutes les réponses
-
-
Hi Richard,
Thanks for your reply. Yes, i have imported it first and then added the script.
string script = "Get-CsServerVersion"; pipeLine.Commands.AddScript(@"Import-Module 'C:\Program Files\Common Files\\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1'"); pipeLine.Commands.AddScript(script);
Also, i want to get the names of the Lync SQL instance and the instances of each database , for which i am trying to use "est-CsDatabase -LocalService" . Can you please help on how to use this cmdlet.
Thanks
- Modifié VKG123 jeudi 10 mars 2016 11:41
-
Hello,
Sorry to inform you that, this cmdlet does not support pipelined input!
Proof: https://technet.microsoft.com/en-us/library/gg398470.aspx
Best Regards Lingaraj Benni Please comment or like, if the above fix resolves your issue.
- Proposé comme réponse Lingaraj Benni jeudi 10 mars 2016 17:30
-