Objects methods missing with import-pssession but working with enter-pssession

303 views Asked by At

I have a small powershell script to run remote against the backup software veeam, but the resulting objects are different.

I connect in two different ways:

  1. Import-PSSession
$cred = Get-Credential -m "Backupserver" -UserName XY
$session = new-PSSession -ComputerName Backupserver -Credential $cred
Invoke-Command -Session $session {add-pssnapin VeeamPSSnapin}
Import-PSSession -Session $session -module VeeamPSSnapin
# but I tried the following too
Import-PSSession -Session $session -DisableNameChecking -AllowClobber
  1. enter-pssession
$cred = Get-Credential -m "Backupserver" -UserName XY
enter-pssession -Credential $cred Backupserver
add-pssnapin VeeamPSSnapin

After that I can use the Veeam Snapin, but the following:

Get-VBRJob -name "Backup Job BITS-SERVER" | Get-Member

Gives me not all methods of the resulting object and not the same object type.

With enter-pssession I got:

   TypeName: Veeam.Backup.Core.CBackupJob

Name                          MemberType Definition
----                          ---------- ----------
CanRunByScheduler             Method     bool ISchedulableJob.CanRunByScheduler()
CheckDeleteAllowed            Method     void CheckDeleteAllowed()
...

With import-pssession I got:

   TypeName: Deserialized.Veeam.Backup.Core.CBackupJob

Name                         MemberType   Definition
----                         ----------   ----------
GetType                      Method       type GetType()
ToString                     Method       string ToString(), string ToString(string format, System.IFormatProvider formatProvider), string IFormattable.ToString(string format, ...
PSComputerName               NoteProperty string PSComputerName=cpa-backup.itservice.de
...

It should be the different type of the resulting object (Deserialized.Veeam.Backup.Core.CBackupJob).

But how can I connect remotely (non interaktive without enter-pssession) to get the same object with all methods???

Thanks in advance...

1

There are 1 answers

1
t1meless On

As PowerShell serializes those objects before sending to you over network you better use Connect-VBRServer cmdlet

Connect-VBRServer -Server "Backupserver"
Get-VBRJob -Name "Backup Job BITS-SERVER" | Get-Member