0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Get-Host behaves differently in PSRemoting.

Posted at

Get-Hostはinvoke-commandで実行すると、なぜか同じバージョン情報を返してくる。Enter-PSSessionで実行しても同じだった。

  • PCXX is Windows11.
  • PCYY is Windows10.
  • localhost is Windows8.1.
PS >(get-host).version

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      14409  1027


PS >$h = ( get-content .\hosts.txt )
PS >$h
PCXX
PCYY
localhost

PS >invoke-command -computername $h -scriptblock { (get-host).version }

Major  Minor  Build  Revision PSComputerName
-----  -----  -----  -------- --------------
1      0      0      0        localhost
1      0      0      0        PCXX
1      0      0      0        PCYY


PS >invoke-command -computername $h -scriptblock { [system.environment]::osversion }


PSComputerName : PCXX
RunspaceId     : **********
Platform       : Win32NT
ServicePack    :
Version        : 10.0.22621.0
VersionString  : Microsoft Windows NT 10.0.22621.0

PSComputerName : localhost
RunspaceId     : ***********
Platform       : Win32NT
ServicePack    :
Version        : 6.3.9600.0
VersionString  : Microsoft Windows NT 6.3.9600.0

PSComputerName : PCYY
RunspaceId     : **********
Platform       : Win32NT
ServicePack    :
Version        : 10.0.19044.0
VersionString  : Microsoft Windows NT 10.0.19044.0

Why?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?