バックアップ ソフトウェア veeam に対してリモートで実行する小さな PowerShell スクリプトがありますが、結果のオブジェクトは異なります。
2 つの異なる方法で接続します。
- インポート-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
- セッション開始
$cred = Get-Credential -m "Backupserver" -UserName XY
enter-pssession -Credential $cred Backupserver
add-pssnapin VeeamPSSnapin
その後、Veeam Snapin を使用できますが、次のようになります。
Get-VBRJob -name "Backup Job BITS-SERVER" | Get-Member
結果のオブジェクトのすべてのメソッドが得られるわけではなく、同じオブジェクトタイプではありません。
enter-pssession を使用すると、次のようになりました。
TypeName: Veeam.Backup.Core.CBackupJob
Name MemberType Definition
---- ---------- ----------
CanRunByScheduler Method bool ISchedulableJob.CanRunByScheduler()
CheckDeleteAllowed Method void CheckDeleteAllowed()
...
import-pssession を使用すると、次のようになりました。
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
...
結果のオブジェクト (Deserialized.Veeam.Backup.Core.CBackupJob) の異なるタイプである必要があります。
しかし、リモートで接続して (enter-pssession なしで非対話的に)、すべてのメソッドで同じオブジェクトを取得するにはどうすればよいですか?
前もって感謝します...