1

I wanted to automate hiding and unhiding partitions (volumes?) for specific users. I usually do it manually through Disk Management by removing the drive letter which causes the drive to disappear from File Explorer.

I ran the following command to hide partition Q (labeled Tic):

Set-Partition -DriveLetter Q -IsHidden $True

It disappeared from File Explorer. Then I went back to Disk Management and reassigned it a letter (I hadn't figured out yet how to do it programmatically). It reappeared in File Explorer. However, diskpart still showed the volume as hidden:

DISKPART> list partition
  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             260 MB  1024 KB
  Partition 2    Reserved            16 MB   261 MB
  Partition 3    Primary            234 GB   277 MB
  Partition 4    Primary            439 GB   234 GB
  Partition 5    Primary             78 GB   674 GB
  Partition 6    Primary             48 GB   849 GB
  Partition 7    Primary             19 GB   898 GB
  Partition 8    Recovery           644 MB   953 GB

DISKPART> list volume Volume ### Ltr Label Fs Type Size Status Info


Volume 0 C Windows NTFS Partition 234 GB Healthy Boot Volume 1 Q Tic NTFS Partition 439 GB Healthy Hidden Volume 2 R Tac NTFS Partition 78 GB Healthy Volume 3 Foo NTFS Partition 48 GB Healthy Volume 4 Bar NTFS Partition 19 GB Healthy Volume 5 SYSTEM FAT32 Partition 260 MB Healthy System Volume 6 Windows RE NTFS Partition 644 MB Healthy Hidden

Notice how volume Tic's Info field says "Hidden" despite me having reassigned it a letter in Disk Management and it (Tic) showing up in File Explorer.

enter image description here

Notice also how volumes Foo and Bar, both of which I hid using Disk Management (not Set-Partition), aren't listed as hidden in diskpart despite not being shown in File Explorer.

Below are PowerShell commandlet output which showed no such discrepancies (although it seems to show less information in general):

PS > Get-Partition
PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                           1048576                                     260 MB System
2                           273678336                                    16 MB Reserved
3                C           290455552                                234.38 GB Basic
4                Q           251948695552                             439.45 GB Basic
5                R           723807895552                              78.12 GB Basic
6                           912551575552                              48.83 GB Basic
7                           964980375552                              19.53 GB Basic
8                           1023527616512                               644 MB Recovery

PS > Get-Volume DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size


R Tac NTFS Fixed Healthy OK 62.91 GB 78.12 GB Bar NTFS Fixed Healthy OK 19.48 GB 19.53 GB Windows RE tools NTFS Fixed Healthy OK 63.11 MB 644 MB C Windows NTFS Fixed Healthy OK 119.32 GB 234.37 GB SYSTEM FAT32 Fixed Healthy OK 193.47 MB 256 MB Foo NTFS Fixed Healthy OK 48.74 GB 48.83 GB

Why is this happening? I've always used "volume" and "partition" interchangeably. Am I supposed to use get-volume and set-volume or get-partition and set-partition when programmatically hiding them?

0 Answers0