powershell - 无法将“System.String”转换为类型“WebServiceProxy.ExternalID”
问题描述
使用 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”。但我似乎无法做到这一点。
任何帮助将不胜感激。
谢谢。
解决方案
推荐阅读
- xslt - XSL 不会写 xmlns:xsl?
- javascript - chartjs:需要 yAxis 比例附近的彩条
- c++ - c ++将模板化函数应用于元组的每个元素
- javascript - 使用 django REST 和 Vue.js 传播不可迭代实例的无效尝试
- ruby-on-rails - 配置异常在生产模式下启动 Web 应用程序 Ruby
- optimization - 在c中具有多重撤消/重做的文本编辑器
- batch-file - 批处理作业删除带有日期和时间戳的文件名中的时间戳
- devops - Artifactory REST API 调用以检索多个工件的最新工件版本
- c# - 如何找到一条线与一个轴对齐的框相交的位置,而该线的至少一个点始终位于该框内?
- python - 将 Tensorflow 模型批量维度重塑为时间序列