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
System One System Two
-
- OS
- Win11 Pro 23H2
- Computer type
- PC/Desktop
- Manufacturer/Model
- Home Built
- CPU
- Intel i7-11700K
- Motherboard
- ASUS Prime Z590-A
- Memory
- 128GB Crucial Ballistix 3200MHz DRAM
- Graphics Card(s)
- No GPU - CPU graphics only (for now)
- Sound Card
- Realtek (on motherboard)
- Monitor(s) Displays
- HP Envy 32
- Screen Resolution
- 2560 x 1440
- Hard Drives
- 1 x 1TB NVMe Gen 4 x 4 SSD
1 x 2TB NVMe Gen 3 x 4 SSD
2 x 512GB 2.5" SSDs
2 x 8TB HD
- PSU
- Corsair HX850i
- Case
- Corsair iCue 5000X RGB
- Cooling
- Noctua NH-D15 chromax.black cooler + 10 case fans
- Keyboard
- CODE backlit mechanical keyboard
- Mouse
- Logitech MX Master 3
- Internet Speed
- 1Gb Up / 1 Gb Down
- Browser
- Edge
- Antivirus
- Windows Defender
- Other Info
- Additional options installed:
WiFi 6E PCIe adapter
ASUS ThunderboltEX 4 PCIe adapter
-
- Operating System
- Win11 Pro 23H2
- 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
- Mouse
- Buttonless Glass Precision Touchpad
- Keyboard
- Backlit, spill resistant keyboard
- 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