-1

I am writing a Powershell script to collect statistics on a couple different things and write to a centralized location.

I tried to do the following:

$storage_pool_stats = Get-StoragePool
$virtual_disk_stats = Get-VirtualDisk

but the results are (ObjectId = "{1}\SERVERNAME\root/Microsoft/Windows/Sto...) instead of the FriendlyName/OperationalStatus/HealthStatus data that is printed to the console when I run "Get-StoragePool"

Does anybody know what I'm doing wrong?

Tristan V
  • 77
  • 1
  • 2
  • 6
  • 1
    The nice table view you see printed in the console by default is controlled by type-specific formatting data (see `Get-FormatData -TypeName 'Microsoft.Management.Infrastructure.CimInstance#MSFT_VirtualDisk'`). What are you trying to accomplish? – Mathias R. Jessen May 17 '17 at 22:11
  • My hope is to collect all the data in that table (The output of 'Get-StoragePool', 'Get-VirtualDisk' (and if I can be greedy, 'Get-PhysicalDisk' too), either as one piece or as individual pieces that I can stitch back together, and dump into a text file. – Tristan V May 17 '17 at 22:19

1 Answers1

0

I'm not sure what the downvotes are all about. For anybody else looking for the answer, writing to a file with Out-File instead seems to keep the formatting. Example below:

$GetPhysicalDisks = Get-PhysicalDisk

$GetPhysicalDisks | Out-File -filepath C:\Utilities\test1.txt
Tristan V
  • 77
  • 1
  • 2
  • 6