小编Sai*_*ham的帖子

远程范围到本地

非常感谢@brianlist,我已经尝试了你的建议,当我使用它与批量复制时,它给了我这个错误,不确定该值是否已传递给$value.

Cannot convert argument "0", with value: "System.Object[]", for "WriteToServer"
to type "System.Data.DataRow[]": "Cannot convert the "System.Data.DataRow" value
of type "Deserialized.System.Data.DataRow" to type "System.Data.DataRow"."
At C:\test\modified.ps1:11 char:24
+ $bulkCopy.WriteToServer <<<< ($value)
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
Run Code Online (Sandbox Code Playgroud)
Get-Content 'C:\test\computers.txt' | ? { $_.trim() -ne "" } | ForEach-Object {
    $value =  Invoke-Command -Computer $_ -ScriptBlock {
        Param($computer)
        #..
        $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
        $global:mdtable = New-Object System.Data.DataTable
        $SqlAdapter.SelectCommand = $SqlCmd
        $nRecs = $SqlAdapter.Fill($mdtable)
        $mdtable …
Run Code Online (Sandbox Code Playgroud)

variables powershell global-variables local

5
推荐指数
1
解决办法
177
查看次数

标签 统计

global-variables ×1

local ×1

powershell ×1

variables ×1