Posh-SSH icon indicating copy to clipboard operation
Posh-SSH copied to clipboard

Set-SCPItem - Object reference not set to an instance of an object.

Open DyJohnnY opened this issue 4 years ago • 5 comments

Hi,

Trying to migrate the set-scpfile commands over to set-scp item and with the latest best 3,0 beta 2 I am getting below error.


$lfile = "C:\Users\myuser\AppData\Local\Temp\runlist.json"
$rpath = "/vmware/input"
$SCPSPlat = @{
    ComputerName      = $VMIP
    Credential        = $Credential
    Destination       = $rpath
    Path              = $lfile
    AcceptKey         = $true
    Force             = $true 
    OperationTimeout  = 30
    ConnectionTimeout = 30
    Verbose           = $true
    Debug = $true
    ErrorAction       = "Stop"
    }
$foo = Set-SCPItem @SCPSPlat
Name                           Value
----                           -----
PSVersion                      5.1.17763.1852
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1852
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

DyJohnnY avatar May 31 '21 10:05 DyJohnnY

Can you also share the error output

Sent from my iPhone

On May 31, 2021, at 6:50 AM, Ionut-Dan Nica @.***> wrote:

 Hi,

Trying to migrate the set-scpfile commands over to set-scp item and with the latest best 3,0 beta 2 I am getting below error.

$lfile = "C:\Users\myuser\AppData\Local\Temp\runlist.json" $rpath = "/vmware/input" $SCPSPlat = @{ ComputerName = $VMIP Credential = $Credential Destination = $rpath Path = $lfile AcceptKey = $true Force = $true OperationTimeout = 30 ConnectionTimeout = 30 Verbose = $true Debug = $true ErrorAction = "Stop" } $foo = Set-SCPItem @SCPSPlat Name Value


PSVersion 5.1.17763.1852 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.1852 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

darkoperator avatar May 31 '21 11:05 darkoperator

There's not much being provided:

Set-SCPItem : Object reference not set to an instance of an object.
At line:1 char:8
+ $foo = Set-SCPItem @SCPSPlat
+        ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Renci.SshNet.ScpClient:ScpClient)
   [Set-SCPItem], NullReferenceException
    + FullyQualifiedErrorId : SSH.SetScpItem

I got this from digging into error variable PS C:> $error[1] | select *

PSMessageDetails      :
Exception             : System.NullReferenceException: Object reference not set to
                        an instance of an object.
                           at SSH.SetScpItem.ProcessRecord()
TargetObject          : Renci.SshNet.ScpClient
CategoryInfo          : OperationStopped: (Renci.SshNet.ScpClient:ScpClient)
                        [Set-SCPItem], NullReferenceException
FullyQualifiedErrorId : SSH.SetScpItem
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

DyJohnnY avatar May 31 '21 11:05 DyJohnnY

Currently on vacation with no laptop will check later this week

Sent from my iPhone

On May 31, 2021, at 7:39 AM, Ionut-Dan Nica @.***> wrote:

 There's not much being provided:

Set-SCPItem : Object reference not set to an instance of an object. At line:1 char:8

  • $foo = Set-SCPItem @SCPSPlat
  •    ~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Renci.SshNet.ScpClient:ScpClient) [Set-SCPItem], NullReferenceException
    • FullyQualifiedErrorId : SSH.SetScpItem

I got this from digging into error variable PS C:> $error[1] | select *

PSMessageDetails : Exception : System.NullReferenceException: Object reference not set to an instance of an object. at SSH.SetScpItem.ProcessRecord() TargetObject : Renci.SshNet.ScpClient CategoryInfo : OperationStopped: (Renci.SshNet.ScpClient:ScpClient) [Set-SCPItem], NullReferenceException FullyQualifiedErrorId : SSH.SetScpItem ErrorDetails : InvocationInfo : System.Management.Automation.InvocationInfo ScriptStackTrace : at <ScriptBlock>, <No file>: line 1 PipelineIterationInfo : {}

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

darkoperator avatar May 31 '21 12:05 darkoperator

Found the bug and that lead me to another one im trying to solve. Will update with another beta soon

darkoperator avatar May 31 '21 22:05 darkoperator

Beta 3 with fix pushed to gallery

darkoperator avatar Jun 01 '21 00:06 darkoperator