I have a command that I am trying to develop that I will call from within a batch file.
I have a large part of this working. Here is what currently works:
powershell.exe -executionpolicy bypass -command "Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 1 -and $_.mbrtype -eq '0x0c' } | Set-Partition -mbrtype '0x1c'; Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 2 -and $_.mbrtype -eq '0x07' } | Set-Partition -mbrtype '0x17'"
This command will look at the first 2 partitions on each drive. If the first partition has an MBR type of 0x0c (a FAT32 MBR partition) it will change the partition type ID to 0x1c, making it hidden.
The same thing is repeated for the second partition, changing the type from 0x07 (an NTFS MBR partition) to 0x17, again, making it hidden.
For safety, I want to add one thing to this command: I want it to look for a file called VOL1_M_MEDIA.WIM or VOL2_M_MEDIA.WIM on the root of the partitions and only change the type if those files are present.
Here is what I have tried, but this is not working. The command completes with no failure, but the type is not being changed even though the expected files are present.
powershell.exe -executionpolicy bypass -command "Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 1 -and $_.mbrtype -eq '0x0c' -and (test-path '$($_.uniqueid)\\VOL1_M_MEDIA.WIM') } | Set-Partition -mbrtype '0x1c'; Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 2 -and $_.mbrtype -eq '0x07' -and (test-path '$($_.uniqueid)\\VOL2_M_MEDIA.WIM') } | Set-Partition -mbrtype '0x17'"
NOTE: I need the command to find the specified files without using a drive letter.
I have a large part of this working. Here is what currently works:
powershell.exe -executionpolicy bypass -command "Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 1 -and $_.mbrtype -eq '0x0c' } | Set-Partition -mbrtype '0x1c'; Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 2 -and $_.mbrtype -eq '0x07' } | Set-Partition -mbrtype '0x17'"
This command will look at the first 2 partitions on each drive. If the first partition has an MBR type of 0x0c (a FAT32 MBR partition) it will change the partition type ID to 0x1c, making it hidden.
The same thing is repeated for the second partition, changing the type from 0x07 (an NTFS MBR partition) to 0x17, again, making it hidden.
For safety, I want to add one thing to this command: I want it to look for a file called VOL1_M_MEDIA.WIM or VOL2_M_MEDIA.WIM on the root of the partitions and only change the type if those files are present.
Here is what I have tried, but this is not working. The command completes with no failure, but the type is not being changed even though the expected files are present.
powershell.exe -executionpolicy bypass -command "Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 1 -and $_.mbrtype -eq '0x0c' -and (test-path '$($_.uniqueid)\\VOL1_M_MEDIA.WIM') } | Set-Partition -mbrtype '0x1c'; Get-Disk | Get-Partition | Where-Object { $_.PartitionNumber -eq 2 -and $_.mbrtype -eq '0x07' -and (test-path '$($_.uniqueid)\\VOL2_M_MEDIA.WIM') } | Set-Partition -mbrtype '0x17'"
NOTE: I need the command to find the specified files without using a drive letter.
My Computers
-
At a glance
Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics- OS
- Win11 Pro 25H2 (RTM+)
- Computer type
- PC/Desktop
- Manufacturer/Model
- Acemagic
- CPU
- Intel i7-14650HX
- Memory
- 32 GB
- Graphics Card(s)
- No GPU - Built-in Intel Graphics
- Sound Card
- Integrated
- Monitor(s) Displays
- Varies as machine will often be moved to locations with different monitors
- Screen Resolution
- Varies
- Hard Drives
- 1 x 1TB Gen 4 NVMe SSD
- PSU
- 120W Power Brick
- Keyboard
- Corsair K70 Max RGB Magnetic Keyboard
- Mouse
- Logitech MX Master 3
- Internet Speed
- 1Gb Up / 1 Gb Down
- Browser
- Edge
- Antivirus
- Windows Defender
-
At a glance
Win11 Pro 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics- Operating System
- Win11 Pro 25H2 (RTM+)
- Computer type
- Laptop
- Manufacturer/Model
- Lenovo ThinkBook 13x Gen 2
- CPU
- Intel i7-1255U
- Memory
- 16 GB
- Graphics card(s)
- Intel Iris Xe Graphics
- Sound Card
- Realtek® ALC3306-CG codec
- Monitor(s) Displays
- 13.3-inch IPS Display
- Screen Resolution
- WQXGA (2560 x 1600)
- Hard Drives
- 2 TB 4 x 4 NVMe SSD
- PSU
- USB-C / Thunderbolt 4 Power / Charging
- Keyboard
- Backlit, spill resistant keyboard
- Mouse
- Buttonless Glass Precision Touchpad
- Internet Speed
- 1Gb Up / 1Gb Down
- Browser
- Edge
- Antivirus
- Windows Defender
- Other Info
- WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor




