Power shell cannot read my TrustedApplicationPoolFqdn parameter
===

power shell give my this error in my log

> Missing an argument for parameter 'TrustedApplicationPoolFqdn'.
> Specify a parameter of type 'Microsoft.Rtc.Management.Deploy.Fqdn' and
> try again.

 

in windows service `OnStart` Method

		  protected override void OnStart(string[] args)
		  {

					 EventLog.WriteEntry("Service Started...");
					 ConfigureServer();
		  }


and this is `CongigureServiser` method 


           public void ConfigureServer()
    {		
    // Get the operating environment to run commands.
    InitialSessionState iss = InitialSessionState.CreateDefault();
    iss.ImportPSModule(new[] { "Lync" });
    using (Runspace myRunSpace = RunspaceFactory.CreateRunspace(iss))
    {
    	 myRunSpace.Open();
    	 string trustedPool = string.Empty;
    	 var domainn = Domain.GetCurrentDomain();
    	 string forest = Forest.GetCurrentForest().ToString();
    	 string dmns = domainn.ToString();
    	 string localHost = System.Net.Dns.GetHostEntry("localhost").HostName;
    	 string fqdn = GetFQDN();
    	 string sipDomain = string.Empty;
    	 // Execute the Get-CsTrustedApplication cmdlet.
    	 using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create())
    	 {
    		  powershell.Runspace = myRunSpace;
    		  powershell.Commands.AddScript("Get-CsTrustedApplicationPool");
    		  Collection<PSObject> results = null;
    		  Collection<ErrorRecord> errors = null;
    		  try
    		  {
    				results = powershell.Invoke();
    				errors = powershell.Streams.Error.ReadAll();
    		  }
    
    		  catch (Exception ex)
    		  {
    		  }
    		  foreach (PSObject result in results)
    		  {
    				string[] ss = result.Members["Identity"].Value.ToString().Split(':');
    				trustedPool = ss[1];
    		  	EventLog.WriteEntry(" the trusted pool is " + trustedPool);
    		  }
    	 }
    	 using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create())
    	 {
    		  powershell.Runspace = myRunSpace;
    		  powershell.Commands.AddScript("Get-CsSipDomain");
    		  Collection<PSObject> results = null;
    		  Collection<ErrorRecord> errors = null;
    		  try
    		  {
    				results = powershell.Invoke();
    				errors = powershell.Streams.Error.ReadAll();
    		  }
    
    		  catch (Exception ex)
    		  {
    		  }
    		  foreach (PSObject result in results)
    		  {
    				sipDomain = result.Members["Identity"].Value.ToString();
    		  }
    	 }
    	 using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create())
    	 {
    		  string localPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
    		  string path = localPath + (@"\msg.am");
    		  powershell.Runspace = myRunSpace;
    		  powershell.Commands.AddScript("New-CsTrustedApplication -ApplicationID OfflineIMApplication -TrustedApplicationPoolFqdn " + trustedPool + " -Port 55555");
    		  powershell.Commands.AddScript("New-CsServerApplication -Identity Registrar:" + fqdn + "/OfflineIMApplication -ScriptName '" + path + "' -Uri http://www.microsoft.com/LCS/OfflineIMApplication -Priority 6 -Critical $False -Enabled $True");
    		  powershell.Commands.AddScript("Enable-CsTopology");
    		  
    		  Collection<PSObject> results = null;
    		  Collection<ErrorRecord> errors = null;
    		  try
    		  {
    				results = powershell.Invoke();
    				errors = powershell.Streams.Error.ReadAll();
    				foreach (ErrorRecord er in errors)
    				{
    					 EventLog.WriteEntry("line 152 power shell"+ er.ToString());
    				}
    		  }
    		  catch (Exception ex)
    		  {
    				EventLog.WriteEntry("from catch" + ex.Message);
    		  }
    	 }
    	 using (System.Management.Automation.PowerShell powershell = System.Management.Automation.PowerShell.Create())
    	 {
    		// some code
    		  myRunSpace.Close();
    		  EventLog.WriteEntry("Forest : " + forest + Environment.NewLine + "Domain : " + dmns + Environment.NewLine + "SipDomain : " + sipDomain + dmns + Environment.NewLine + "Fqdn : " + fqdn);
    	 }
    	 Thread.Sleep(3000);
    	 _app = new Thread(new ThreadStart(UCMASampleSubscribePresenceView.InitializeApplication));
    	 _app.Start();
    }
    			
    }

