Hello,
I’m having a hard time using the Select-Object
to output only two of four objects available in the output.
For example, the output below shows Index
, Name
, Description
and Size
. I would like to output only Index
and Name
.
Perhaps I’m wrong about these being objects…? If they are, am I just using Select-Object
incorrectly?
My code looks like this:
$wrs_local="C:\Mounts\WindowsRepairSource"
dism /Get-WimInfo /WimFile:"$wrs_local\RepairSource.wim"
The code results in the following output:
Deployment Image Servicing and Management tool
Version: 10.0.19041.844
Details for image : C:\Mounts\WindowsRepairSource\RepairSource.wim
Index : 1
Name : Windows 10 Pro for Workstations
Description : Windows 10 Pro for Workstations
Size : 15,074,686,984 bytes
Index : 2
Name : Windows 11 Pro
Description : Windows 11 Pro
Size : 16,198,033,078 bytes
The operation completed successfully.
Output repeats for each Index; up to #6 in my case.
I thought I could use Select-Object
to limit the output to only Index
and Name
.
dism /Get-WimInfo /WimFile:"$wrs_local\RepairSource.wim" | Select-Object Index,Name
However, when I do, I only get this:
Index Name
----- ----
… followed by a bunch of blank lines with 10 empty spaces each, including one that I think is supposed to contain the following: The operation completed successfully.
I was hoping to get something like this:
Deployment Image Servicing and Management tool
Version: 10.0.19041.844
Details for image : C:\Mounts\WindowsRepairSource\RepairSource.wim
Index : 1
Name : Windows 10 Pro for Workstations
Index : 2
Name : Windows 11 Pro
The operation completed successfully.
Or just this:
Index : 1
Name : Windows 10 Pro for Workstations
Index : 2
Name : Windows 11 Pro
I’m using Microsoft’s Select-Object for reference.
Any insight would be greatly appreciated.