使用API,我相信我需要创建一个WebserviceProxy对象并向其添加属性“ ExternalID”,但是我似乎找不到正确的代码来执行此操作。
这是我得到的错误...
Cannot convert argument "0", with value: "002374E4DBEC", for "LaunchClientApplication" to type "WebServiceProxy.ExternalId": "Cannot convert the "002374E4DBEC" value of type "System.String" to type "WebServiceProxy.ExternalId"."
At C:\PowerShellScripts\Crawler.ps1:72 char:50
+ $guid = $OSSNBranchWS.LaunchClientApplication <<<< ($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
这是我的代码...
### Crawler
### SQL Login
$SQLUser = "USERNAME"
$SQLPassword = "PASSWORD"
$SQLServer = "SQLSERVER\DB"
$SQLDBName = "SQLDB"
$SqlQuery = "select a.externalID as Acct_Number, d.externalId as Ext_Device_ID
from bm_account a inner join
bm_device d on a.accountId = d.accountId
where a.externalId='9999999999'
order by Acct_Number,Ext_Device_ID"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User ID = $SQLUser; Password = $SQLPassword;"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$rowCount = $SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$FTCSTBExternalIDs = $DataSet.Tables[0]
$Domain = 'DM'
$UserName = 'USERNAME'
$Password = 'PASSWORD'
$UsernameDomain = $Domain+'\'+$UserName
$SecurePassword=ConvertTo-SecureString -String $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential $UsernameDomain,$SecurePassword
$OSSNBranchWS = New-WebServiceProxy -Uri "http://mediaroomserver/ossNotificationsWS/UI.asmx?wsdl" -Namespace WebServiceProxy -Credential $Credential
$applicationUri = "page:http://mediaroomserver.com/FTCPFApps/STBScrollingMessages/MediaroomPage.aspx"
ForEach ($FTCSTBExternalID in $FTCSTBExternalIDs)
{
$msg_time = Get-Date -UFormat "%Y-%m-%d %r"
$message = $msg_time+' - FTC Account Number: "'+$FTCSTBExternalID.Acct_Number+'", Device ID: "'+$FTCSTBExternalID.Ext_Device_ID+'"' | Out-File $log_file -Append
$guid = $OSSNBranchWS.LaunchClientApplication($FTCSTBExternalID.Ext_Device_ID,$applicationUri)
}
似乎我需要将“ $ FTCSTBExternalID”更改为WebserviceProxy对象,并向其中添加属性“ ExternalID”,然后向其中添加“ $ FTCSTBExternalID.Ext_Device_ID”。但是我似乎无法做到这一点。
任何帮助将不胜感激。
谢谢。