逻辑驱动器信息

问题描述

| 我有一个声明为$ outputs = @()的脚本 &在其中添加了一组属性,这是相同的结果,即时消息是使用$ output | Add-MemberType -MemberType注意属性-Name \“ hostname \” -Value \“ $ hostname \”,其他属性也是如此。我在做$ outputs + = $ output以添加附加值, 主机名:SEAPS01 日期:06/14/2011 02:06:36 已安装的应用程序:Microsoft SQL Server 2008客户端工具 但是现在的问题是,当我向其中添加硬盘信息时,它被改写了,并且由于note属性已经存在,因此我收到错误消息,请您帮我了解如何将硬盘属性添加到$ outputs对象中 $ colItems = get-wmiobject -class \“ Win32_LogicalDisk \”-命名空间\“ root \\ CIMV2 \”-计算机名$ compname
$drivecount=(get-wmiobject -class \"Win32_LogicalDisk\" -namespace \"root\\CIMV2\" | Select-Object drivetype | Measure-Object).count




foreach ($objItem in $colItems){
for($j=0;$j-lt$drivecount;$j++){
if ($objItem.DriveType -eq 3){
    # Write to screen
    #write-host \"Drive Type: \" $objItem.DriveType
    $drivename=$objItem.Name



    # Improve the display of the higher order values of MB and GB 
    $displayMB = [math]::round($objItem.Size/1024/1024,2)
    $displayGB = [math]::round($objItem.Size/1024/1024/1024,2)

    $strOutPut57 = $displayGB

    # Improve the display of the higher order values of MB and GB 
    $displayMB = [math]::round($objItem.FreeSpace/1024/1024,2)
    $displayGB = [math]::round($objItem.FreeSpace/1024/1024/1024,2)

    $strOutPut58 = $objItem.Name +\"\\ \"+ $displayGB
    $strOutPut59 = $objItem.FileSystem

$output | Add-Member -MemberType Noteproperty -Name DriveName[$j] -Value \"$drivename\"
$output | Add-Member -MemberType Noteproperty -Name FilesystemType[$j] -Value \"$strOutPut59\"
$output | Add-Member -MemberType Noteproperty -Name Size[$j] -Value \"$strOutPut57\"
$output | Add-Member -MemberType Noteproperty -Name FreeSpace[$j] -Value \"$strOutPut58\"
}




}
}
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)