- $LogicalDisks = (Get-WmiObject Win32_Volume -Filter "DriveType='3'" | select -expand DriveLetter ) -join '|'
- $obj | Add-Member -membertype NoteProperty -Name DriveLetter -Value $LogicalDisks
psobject results not as expected
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: psobject results not as expected
OR ...
Re: psobject results not as expected
Thank you your ForEach-Object suggestion did the trick!MikeFRobbins wrote:Where-Object in the first line of adding members in your script doesn't do anything. Changing it to ForEach-Object at least narrows it down to only the drive letter property:Code: Select all
$obj | Add-Member -membertype NoteProperty -Name DriveLetter -Value (($LogicalDisks | ForEach-Object { $_.DriveLetter } ) | out-string).Trim()