如何只从下面的PS命令返回一个值?
PS C:\Users\vagrant> winrm get winrm/config/winrs
Winrs
AllowRemoteShellAccess = true
IdleTimeout = 7200000
MaxConcurrentUsers = 10
MaxShellRunTime = 2147483647
MaxProcessesPerShell = 25
MaxMemoryPerShellMB = 300
MaxShellsPerUser = 30具体来说,我只想得到MaxMemoryPerShellMB的值。最终,我需要将该值与另一个值进行比较,以便确保在需要时正确设置它。
发布于 2015-06-16 17:42:37
您可以使用WS-Management提供程序获取或设置WS-Management配置选项:
(Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB).Value 什么是WSMan,它与winrm相比是什么?
你可以说,它们基本上都指的是同一件事:
Windows远程管理(WinRM)是微软实现的WS-管理协议,这是一个标准的简单对象访问协议(SOAP)-based,防火墙友好协议,允许硬件和操作系统,从不同的供应商,互操作。来源
winrm get winrm/config的所有选项都可以在WSMan:\localhost\ PowerShell路径下使用。它们中的一些可以使用不同的命名方式,比如Shell而不是winrs (Window Remote Shell),但在大多数情况下名称是匹配的。您可以通过标准PowerShell命令(如dir WSMan:\localhost\ )探索可用的配置选项。
发布于 2015-06-16 17:14:49
可以将winrm输出转换为哈希表
$winrs = & winrm get winrm/config/winrs |
Select-Object -Skip 1 |
Out-String |
ConvertFrom-StringData并访问如下所需的值:
$winrs['MaxMemoryPerShellMB']或者像这样:
$winrs.MaxMemoryPerShellMBhttps://stackoverflow.com/questions/30873626
复制相似问题