2

このスクリプトを呼び出すと、例外が発生します

文字列にターミネータがありません: "

 using (var powershell = PowerShell.Create())
                {
                    powershell.Runspace = myRunSpace;
                    Collection<ErrorRecord> errors = null;
                    Collection<PSObject> result = null;

                    string psScript = @"
                                            $ApplicationID=" + applicationID +
                                      "\n" +
                                      "$ApplicationPort" + port + "\n" +
                                      "$Registrar=" + registrar + "\n" +
                                      "$NewPoolIdentity=" + poolIdentity + "\n" +
                                      "$ScriptName =" + scriptName + "\n" +
                                      "$SiteName= (get-cspool -Identity $Registrar).Site" + "\n" +
                                      "$Site= (get-cssite -Identity $SiteName).SiteId" + "\n" +
                                      "$ComputerFqdn =[System.Net.Dns]::GetHostByName(($env:computerName)).HostName" +
                                      "\n" +
                                      "$com=New-Object -ComObject CertificateAuthority.Config" + "\n" +
                                      "$CertificationAuthority = $com.GetConfig(0)" + "\n" +
                                      "$CertificateFriendlyName =$NewPoolIdentity +\" Pool" + "\n" +
                                      "$ApplicationFullID =$ApplicationID+ $ApplicationPort" + "\n" +
                                      "$DefaultSipDomain = (Get-CsSipDomain | where-object { $_.IsDefault -eq $true}).Name" +
                                      "\n" +
                                      "$ApplicationSipAddress = \"sip:\" + $ApplicationFullID + \"@\" + $DefaultSipDomain" +
                                      "\n" +
                                      "New-CsTrustedApplicationPool -Identity $NewPoolIdentity -Registrar $Registrar -RequiresReplication $false -Site $Site -ComputerFqdn $ComputerFqdn" +
                                      "\n" +
                                      "$MyTrustedApplications=New-CSTrustedApplication –ApplicationId $ApplicationFullID -TrustedApplicationPoolFqdn $NewPoolIdentity -Port $ApplicationPort" +
                                      "\n" +
                                      "Enable-CsTopology" + "\n" +
                                      "$Cert=Request-CsCertificate -New -Type default -FriendlyName $CertificateFriendlyName -CA $CertificationAuthority -ComputerFQDN $ComputerFqdn" +
                                      "\n" +
                                      "Set-CsCertificate -Type Default -Thumbprint $Cert.Thumbprint" + "\n" +
                                      "$ApplicationIdentity =  \"Registrar:\"+ $Registrar + \"/\" + $ApplicationFullID " +
                                      "\n" +
                                      "$ApplicationURI= \"http://www.sdsdsds.com/Apps/\" + $ApplicationID" + "\n" +
                                      "New-CsServerApplication -Identity $ApplicationIdentity -ScriptName $ScriptName -Uri $ApplicationURI -Priority 6 -Critical $False -Enabled $True" +
                                      "\n" +
                                      "New-CsTrustedApplicationEndpoint -ApplicationId $ApplicationFullID -TrustedApplicationPoolFqdn $NewPoolIdentity -SipAddress $ApplicationSipAddress" +
                                      "\n" +
                                      " $FinalResult = new-object PSObject;" +
                                      "\n" +
                                      "$FinalResult | add-member NoteProperty -Name Gruu $MyTrustedApplications.ComputerGruuS[0].Gruu;" +
                                      "\n" +
                                      "$FinalResult | add-member NoteProperty -Name LocalMachineFqdn $MyTrustedApplications.ComputerGruuS[0].Fqdn; " +
                                      "\n" +
                                      "$FinalResult | add-member NoteProperty -Name Port $MyTrustedApplications.Port; " +
                                      "\n" +
                                      "$FinalResult | add-member NoteProperty -Name ApplicationPoolFqdn $MyTrustedApplications.TrustedApplicationPoolFqdn; " +
                                      "\n" +
                                      "$FinalResult | add-member NoteProperty -Name Registrar $TrustedApplicationPool.Registrar; " +
                                      "\n" +
                                      "$FinalResult | add-member NoteProperty -Name CertificateFriendlyName $CertificateFriendlyName" +
                                      "\n" +
                                      "$FinalResult | add-member NoteProperty -Name ApplicationSipAddress $ApplicationSipAddress" +
                                      "\n" + "$FinalResult";



                    powershell.Commands.AddScript(psScript);


                    try
                    {
                        result = powershell.Invoke();
                        errors = powershell.Streams.Error.ReadAll();
                        Console.Write(".");
                    }

誰でもエラーを見つけるのに役立ちます

4

1 に答える 1