0
ドメイン内のサーバーから情報を確認したいことがあります。この例では、私はリモートで(現在はループせずにただ一つのサーバ、)Windowsのバージョンを取得しようとしています:Powershell:Get-WmiObjectはループ内でJobとして実行できません
$cr=Get-Credential "domain\adm_user"
$computer="serverA"
Invoke-Command { Get-WmiObject -Class Win32_OperatingSystem -Namespace root/cimv2 -Computer $computer -Credential $cr | Format-List -Property Name, OSArchitecture, SerialNumber} -AsJob -ComputerName .
Get-Job | Wait-Job
Get-Job | Receive-Job
出力:
Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
ようだ、そのスクリプトブロックは{}変数$computer
を見ることはできません。 変数-computer $computer
をサーバの名前に置き換えると、動作しています。 Invoke-Commandコマンド内部変数の展開については
正しいパラメータは '-ComputerName'です - あなたは-Computerを使用していますか? – Jelphy
ComputerとComputerNameはエイリアスです。私は長い名前を試して、出力(エラー)は同じです。 – Jerry1