我正在运行一个脚本来获取下面给出的磁盘级别信息。
磁盘.ps1:
Get-WmiObject Win32_DiskDrive | % {
$disk = $_
$partitions = "ASSOCIATORS OF " +
"{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " +
"WHERE AssocClass = Win32_DiskDriveToDiskPartition"
Get-WmiObject -Query $partitions | % {
$partition = $_
$drives = "ASSOCIATORS OF " +
"{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " +
"WHERE AssocClass = Win32_LogicalDiskToPartition"
Get-WmiObject -Query $drives | % {
New-Object -Type PSCustomObject -Property @{
Disk = $disk.SerialNumber
Letter = $_.DeviceID
}
}
}
}
当我在 Windows 机器上执行上述代码段时,输出为:
字母盘 ------ ---- H:XXX_46_0_80987_XXXXX_b2fd_47bb_bc36_aaf4f3029a00 L: XXX_46_0_80987_XXXXX_b2fd_47bb_bc36_aaf4f3029a00 问:XXX_46_0_80987_41a13cd9_b2fd_47bb_bc36_aaf4f3029a00
现在我正在尝试使用pywinrm
.
磁盘.py:
complete = <string which is equivalent to above script>
winrm_connector = winrm.Session('*.X.X.X', auth=('XXXX','XXXXXX.1'))
response = winrm_connector.run_ps(complete)
print response.std_out
执行这个我得到输出:
字母盘 ------ ---- H:XXX_46_0_80987_XXXXX_b2fd_47bb_b... L: XXX_46_0_80987_XXXXX_b2fd_47bb_b... 问:XXX_46_0_80987_41a13cd9_b2fd_47bb_b...
请说明 WinRM 是在截断输出还是 shell 是在截断输出。
我认为 shell 没有这样做,因为当我使用 PowerShell 执行脚本时,我能够获得整个输出。