0
PowerShell ps = PowerShell.Create();
PSCommand cmd1 = new PSCommand();

 cmd1.AddCommand("Grant-CsTenantDialPlan")
.AddParameter("Identity", "xxxx.yyyy@xxxxx.com.tr")
.AddParameter("PolicyName", "DialPlan-GMMA");

 ps.Commands = cmd1;
 ps.Invoke();

I'm not sending the PolicyName parameter empty. But why am I still getting the error?

Stack Trace:

at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke) at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync) at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings) at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings) at System.Management.Automation.PowerShell.Invoke() at ConnectTeams.Program.Main(String[] args) in C:\Projects\ConnectTeams\ConnectTeams\Program.cs:line 120

mgk
  • 1
  • 3
  • We can't guess without the actual full exception text. That tells you where the error occurred, which method threw it, whether there was an inner exception and which chain of calls caused this. You can easily get the full exception text with `Exception.ToString()` or by clicking on `Copy Details` in the exception popup while debugging. Right now we don't even know if that's the code that throws or some other code right after `Invoke()` – Panagiotis Kanavos Mar 14 '23 at 08:17
  • BTW this question will probably be closed as a duplicate of [What is a NullReferenceException and How do I fix it](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) unless you post something that shows that eg the problem was raised inside `Grant-CsTenantDialPlan`. Perhaps there's no Skype installed on the machine? – Panagiotis Kanavos Mar 14 '23 at 08:20
  • I updated my question, added a stack trace. I want to run the command Grant-CsOnlineTenantDialPlan in Microsoft Teams. I can connect to Microsoft Teams, no problem. But I am getting an error in this command and other commands with PolicyName parameter. @Panagiotis Kanavos – mgk Mar 14 '23 at 08:45
  • Post the *full* exception text, not just the stack trace. Teams and Skype For Business are two completely different products. Skype For Business isn't even Skype, it's the Microsoft Lync/Microsoft Communicator of the 2010s that was renamed `Skype For Business` when Skype was acquired. Teams is a replacement for that and MS is mothballing it. Don't assume it's installed – Panagiotis Kanavos Mar 14 '23 at 08:47

0 Answers0