Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:49:12+00:00 2026-05-23T06:49:12+00:00

I have a script which has a declaration of $outputs=@() & into which a

  • 0

I have a script which has a declaration of $outputs=@()

& into which a set of properties get added, here is an out out for the same, im getting these added using $output | Add-Member -MemberType Noteproperty -Name “hostname” -Value “$hostname”, similarly for others properties too. im doing an $outputs+=$output to add the appended values,

hostname : SEAPS01
date : 06/14/2011 02:06:36
ApplicationsInstalled : Microsoft SQL Server 2008 Client Tools

but now the problem is that when i add hard disk info to this it gets owerwritten & i recieve an error as the note property already exists, could you please help me out on how to go about & append the HDD properties to the $outputs object

$colItems = get-wmiobject -class “Win32_LogicalDisk” -namespace “root\CIMV2” -computername $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"
}




}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:49:13+00:00Added an answer on May 23, 2026 at 6:49 am

    Add-member is not necessary in this case, you can manupulate the output with Select-Object and custom properties

    Get-WmiObject Win32_LogicalDisk -Filter 'drivetype=3' | Select-Object Name,FileSystem,VolumeName,@{Name='FreeSpace(GB)';Expression={$_.FreeSpace/1GB}},@{Name='Size(GB)';Expression={$_.Size/1GB}}
    

    Your example code also be simplified to this (no need to reassign to $outputs and the result is streaming, objects come out of the pipeline once it’s created)

    Get-WmiObject Win32_LogicalDisk -Filter 'drivetype=3' | Foreach-Object{
        New-Object PSObject -Property @{
             Name         = $_.caption
             FileSystem   = $_.filesystem
             FreeSpace    = $_.freespace/1GB
             Size         = $_.size/1GB
             VolumeName   = $_.volumename
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my front end script which has the following jQuery code: $.get(/backend/post.php, {
I have an ASP.NET page which has a script manager on it. <form id=form1
I have a script which tracks visits & referers to a website. I send
I have a WSDL script which has the following format <definitions name=ProcessData targetNamespace=urn:ProcessData> <message
I have a Capistrano deploy.rb script which has multiple tasks that can be invoked
I have small PHP script which has $query = SELECT MAX(id) FROM `dbs`; //query
I have a bash shell script which has the line: g=$(/bin/printf ${i}) when ${i}
I have a bat script which has block1 commands. I call the block1 like
I have a js script which has only one variable, but that variable holds
I have a PHP Script which has several text areas. What I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.