Get the sector size of a drive letter without using fsutil












2















I need to know how to get the sector size for a drive letter, eg C:, without using fsutil in a PowerShell script. Batch and VBS are also acceptable.

The fsutil tool is perfect for this as it returns the exact data I need:



fsutil fsinfo ntfsinfo C:
NTFS Volume Serial Number : 0x32946b93946b587d
NTFS Version : 3.1
LFS Version : 2.0
Number Sectors : 0x000000003a0b6c84
Total Clusters : 0x0000000007416d90
Free Clusters : 0x00000000010a9da5
Total Reserved : 0x0000000000002c98
Bytes Per Sector : 512
Bytes Per Physical Sector : 512
Bytes Per Cluster : 4096
Bytes Per FileRecord Segment : 1024
--- etc ---


However, I am using this script in an environment where there are lots of different languages of Windows in use, and Microsoft in their infinite wisdom decided to translate the output:



fsutil fsinfo ntfsinfo c:
NTFS-Volumeseriennummer : 0xdc7ccd5b7ccd3156
NTFS-Version : 3.1
LFS-Version : 2.0
Anzahl der Sektoren : 0x0000000004eec7ff
Gesamtzahl Cluster : 0x00000000009dd8ff
Freie Cluster : 0x000000000059183d
Insgesamt reserviert : 0x000000000000430e
Bytes pro Sektor : 512
Bytes pro physischem Sektor : 512
Bytes pro Cluster : 4096
Bytes pro Dateidatensatzsegment : 1024
--- usw ---


The information I need – bytes per sector – does not appear to be readily available from the WMI such that I can say "give me the data for C:", and attempts to pair disk-level data with volume-level data to try and patch together a query have been unsuccessful.



I'd hard-code the line number to get the data back from, but the amount of data returned from fsutil is inconsistent across versions of Windows. Both the examples above were taken from Windows 10 devices, where the data I need is on line 8, but on Windows 7 devices it is on line 7.



Does anyone know of a way for me to get this data such that i18n will not interfere with it? The only alternative is to hard-code the line number I need the data from, with accommodations made for the version of Windows I am running, which is too unreliable to consider.



I am looking for the "Bytes per Sector", not the "Bytes per physical sector" value.










share|improve this question























  • The "Bytes per Sector" only reports the logical sector size. This will be almost always 512. Any other size will cause the malfunctioning of many Windows utilities.

    – harrymc
    Jan 25 at 17:36











  • support.microsoft.com/en-us/help/2510009/… -- it can also read 4096 for AF format drives.

    – seagull
    Jan 25 at 17:43













  • Windows 8+ can basically run in 4K native mode, but not all applications. See the section "Known compatibility issues" in this article. I currently see "Bytes per Sector" equal to 512 even on new 10 TB disks, so I believe you will need to make an effort to get a real 4K native disk.

    – harrymc
    Jan 25 at 17:50











  • Notwithstanding, it's important that I can get the information on the offchance the data is not 512. I'd love to assume 512 and be done with it but it'd only bite me eventually.

    – seagull
    Jan 25 at 18:06
















2















I need to know how to get the sector size for a drive letter, eg C:, without using fsutil in a PowerShell script. Batch and VBS are also acceptable.

The fsutil tool is perfect for this as it returns the exact data I need:



fsutil fsinfo ntfsinfo C:
NTFS Volume Serial Number : 0x32946b93946b587d
NTFS Version : 3.1
LFS Version : 2.0
Number Sectors : 0x000000003a0b6c84
Total Clusters : 0x0000000007416d90
Free Clusters : 0x00000000010a9da5
Total Reserved : 0x0000000000002c98
Bytes Per Sector : 512
Bytes Per Physical Sector : 512
Bytes Per Cluster : 4096
Bytes Per FileRecord Segment : 1024
--- etc ---


However, I am using this script in an environment where there are lots of different languages of Windows in use, and Microsoft in their infinite wisdom decided to translate the output:



fsutil fsinfo ntfsinfo c:
NTFS-Volumeseriennummer : 0xdc7ccd5b7ccd3156
NTFS-Version : 3.1
LFS-Version : 2.0
Anzahl der Sektoren : 0x0000000004eec7ff
Gesamtzahl Cluster : 0x00000000009dd8ff
Freie Cluster : 0x000000000059183d
Insgesamt reserviert : 0x000000000000430e
Bytes pro Sektor : 512
Bytes pro physischem Sektor : 512
Bytes pro Cluster : 4096
Bytes pro Dateidatensatzsegment : 1024
--- usw ---


The information I need – bytes per sector – does not appear to be readily available from the WMI such that I can say "give me the data for C:", and attempts to pair disk-level data with volume-level data to try and patch together a query have been unsuccessful.



I'd hard-code the line number to get the data back from, but the amount of data returned from fsutil is inconsistent across versions of Windows. Both the examples above were taken from Windows 10 devices, where the data I need is on line 8, but on Windows 7 devices it is on line 7.



Does anyone know of a way for me to get this data such that i18n will not interfere with it? The only alternative is to hard-code the line number I need the data from, with accommodations made for the version of Windows I am running, which is too unreliable to consider.



I am looking for the "Bytes per Sector", not the "Bytes per physical sector" value.










share|improve this question























  • The "Bytes per Sector" only reports the logical sector size. This will be almost always 512. Any other size will cause the malfunctioning of many Windows utilities.

    – harrymc
    Jan 25 at 17:36











  • support.microsoft.com/en-us/help/2510009/… -- it can also read 4096 for AF format drives.

    – seagull
    Jan 25 at 17:43













  • Windows 8+ can basically run in 4K native mode, but not all applications. See the section "Known compatibility issues" in this article. I currently see "Bytes per Sector" equal to 512 even on new 10 TB disks, so I believe you will need to make an effort to get a real 4K native disk.

    – harrymc
    Jan 25 at 17:50











  • Notwithstanding, it's important that I can get the information on the offchance the data is not 512. I'd love to assume 512 and be done with it but it'd only bite me eventually.

    – seagull
    Jan 25 at 18:06














2












2








2








I need to know how to get the sector size for a drive letter, eg C:, without using fsutil in a PowerShell script. Batch and VBS are also acceptable.

The fsutil tool is perfect for this as it returns the exact data I need:



fsutil fsinfo ntfsinfo C:
NTFS Volume Serial Number : 0x32946b93946b587d
NTFS Version : 3.1
LFS Version : 2.0
Number Sectors : 0x000000003a0b6c84
Total Clusters : 0x0000000007416d90
Free Clusters : 0x00000000010a9da5
Total Reserved : 0x0000000000002c98
Bytes Per Sector : 512
Bytes Per Physical Sector : 512
Bytes Per Cluster : 4096
Bytes Per FileRecord Segment : 1024
--- etc ---


However, I am using this script in an environment where there are lots of different languages of Windows in use, and Microsoft in their infinite wisdom decided to translate the output:



fsutil fsinfo ntfsinfo c:
NTFS-Volumeseriennummer : 0xdc7ccd5b7ccd3156
NTFS-Version : 3.1
LFS-Version : 2.0
Anzahl der Sektoren : 0x0000000004eec7ff
Gesamtzahl Cluster : 0x00000000009dd8ff
Freie Cluster : 0x000000000059183d
Insgesamt reserviert : 0x000000000000430e
Bytes pro Sektor : 512
Bytes pro physischem Sektor : 512
Bytes pro Cluster : 4096
Bytes pro Dateidatensatzsegment : 1024
--- usw ---


The information I need – bytes per sector – does not appear to be readily available from the WMI such that I can say "give me the data for C:", and attempts to pair disk-level data with volume-level data to try and patch together a query have been unsuccessful.



I'd hard-code the line number to get the data back from, but the amount of data returned from fsutil is inconsistent across versions of Windows. Both the examples above were taken from Windows 10 devices, where the data I need is on line 8, but on Windows 7 devices it is on line 7.



Does anyone know of a way for me to get this data such that i18n will not interfere with it? The only alternative is to hard-code the line number I need the data from, with accommodations made for the version of Windows I am running, which is too unreliable to consider.



I am looking for the "Bytes per Sector", not the "Bytes per physical sector" value.










share|improve this question














I need to know how to get the sector size for a drive letter, eg C:, without using fsutil in a PowerShell script. Batch and VBS are also acceptable.

The fsutil tool is perfect for this as it returns the exact data I need:



fsutil fsinfo ntfsinfo C:
NTFS Volume Serial Number : 0x32946b93946b587d
NTFS Version : 3.1
LFS Version : 2.0
Number Sectors : 0x000000003a0b6c84
Total Clusters : 0x0000000007416d90
Free Clusters : 0x00000000010a9da5
Total Reserved : 0x0000000000002c98
Bytes Per Sector : 512
Bytes Per Physical Sector : 512
Bytes Per Cluster : 4096
Bytes Per FileRecord Segment : 1024
--- etc ---


However, I am using this script in an environment where there are lots of different languages of Windows in use, and Microsoft in their infinite wisdom decided to translate the output:



fsutil fsinfo ntfsinfo c:
NTFS-Volumeseriennummer : 0xdc7ccd5b7ccd3156
NTFS-Version : 3.1
LFS-Version : 2.0
Anzahl der Sektoren : 0x0000000004eec7ff
Gesamtzahl Cluster : 0x00000000009dd8ff
Freie Cluster : 0x000000000059183d
Insgesamt reserviert : 0x000000000000430e
Bytes pro Sektor : 512
Bytes pro physischem Sektor : 512
Bytes pro Cluster : 4096
Bytes pro Dateidatensatzsegment : 1024
--- usw ---


The information I need – bytes per sector – does not appear to be readily available from the WMI such that I can say "give me the data for C:", and attempts to pair disk-level data with volume-level data to try and patch together a query have been unsuccessful.



I'd hard-code the line number to get the data back from, but the amount of data returned from fsutil is inconsistent across versions of Windows. Both the examples above were taken from Windows 10 devices, where the data I need is on line 8, but on Windows 7 devices it is on line 7.



Does anyone know of a way for me to get this data such that i18n will not interfere with it? The only alternative is to hard-code the line number I need the data from, with accommodations made for the version of Windows I am running, which is too unreliable to consider.



I am looking for the "Bytes per Sector", not the "Bytes per physical sector" value.







hard-drive powershell wmi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 25 at 16:29









seagullseagull

2,66751630




2,66751630













  • The "Bytes per Sector" only reports the logical sector size. This will be almost always 512. Any other size will cause the malfunctioning of many Windows utilities.

    – harrymc
    Jan 25 at 17:36











  • support.microsoft.com/en-us/help/2510009/… -- it can also read 4096 for AF format drives.

    – seagull
    Jan 25 at 17:43













  • Windows 8+ can basically run in 4K native mode, but not all applications. See the section "Known compatibility issues" in this article. I currently see "Bytes per Sector" equal to 512 even on new 10 TB disks, so I believe you will need to make an effort to get a real 4K native disk.

    – harrymc
    Jan 25 at 17:50











  • Notwithstanding, it's important that I can get the information on the offchance the data is not 512. I'd love to assume 512 and be done with it but it'd only bite me eventually.

    – seagull
    Jan 25 at 18:06



















  • The "Bytes per Sector" only reports the logical sector size. This will be almost always 512. Any other size will cause the malfunctioning of many Windows utilities.

    – harrymc
    Jan 25 at 17:36











  • support.microsoft.com/en-us/help/2510009/… -- it can also read 4096 for AF format drives.

    – seagull
    Jan 25 at 17:43













  • Windows 8+ can basically run in 4K native mode, but not all applications. See the section "Known compatibility issues" in this article. I currently see "Bytes per Sector" equal to 512 even on new 10 TB disks, so I believe you will need to make an effort to get a real 4K native disk.

    – harrymc
    Jan 25 at 17:50











  • Notwithstanding, it's important that I can get the information on the offchance the data is not 512. I'd love to assume 512 and be done with it but it'd only bite me eventually.

    – seagull
    Jan 25 at 18:06

















The "Bytes per Sector" only reports the logical sector size. This will be almost always 512. Any other size will cause the malfunctioning of many Windows utilities.

– harrymc
Jan 25 at 17:36





The "Bytes per Sector" only reports the logical sector size. This will be almost always 512. Any other size will cause the malfunctioning of many Windows utilities.

– harrymc
Jan 25 at 17:36













support.microsoft.com/en-us/help/2510009/… -- it can also read 4096 for AF format drives.

– seagull
Jan 25 at 17:43







support.microsoft.com/en-us/help/2510009/… -- it can also read 4096 for AF format drives.

– seagull
Jan 25 at 17:43















Windows 8+ can basically run in 4K native mode, but not all applications. See the section "Known compatibility issues" in this article. I currently see "Bytes per Sector" equal to 512 even on new 10 TB disks, so I believe you will need to make an effort to get a real 4K native disk.

– harrymc
Jan 25 at 17:50





Windows 8+ can basically run in 4K native mode, but not all applications. See the section "Known compatibility issues" in this article. I currently see "Bytes per Sector" equal to 512 even on new 10 TB disks, so I believe you will need to make an effort to get a real 4K native disk.

– harrymc
Jan 25 at 17:50













Notwithstanding, it's important that I can get the information on the offchance the data is not 512. I'd love to assume 512 and be done with it but it'd only bite me eventually.

– seagull
Jan 25 at 18:06





Notwithstanding, it's important that I can get the information on the offchance the data is not 512. I'd love to assume 512 and be done with it but it'd only bite me eventually.

– seagull
Jan 25 at 18:06










3 Answers
3






active

oldest

votes


















1














Here is a command that will get the logical sector size, tested on Windows 7 and
on Windows 10:



wmic partition where "DeviceID like '%Disk #0%#0%'" get BlockSize  | findstr /v BlockSize


Or for the boot partition:



wmic partition where BootPartition=TRUE get BlockSize  | findstr /v BlockSize


Or even:



wmic partition where (BootPartition=TRUE and Type='GPT: System') get BlockSize  | findstr /v BlockSize


The command gets the information for the partition whose DeviceID is like
the specified string. The DeviceID of the first disk will be
"Disk #0, Partition #0", for the second disk it will be
"Disk #1, Partition #0" etc.
The findstr command is required to get rid of the header line.
Elevated permissions are not required for this.



This is the result on my computer:



enter image description here






share|improve this answer


























  • This is great, thank you. I tried "wmic partition > textfile.txt" but I wasn't seeing any disk labels in there. That double-hash-zero-percent is witchcraft, would you be able to explain what it's doing?

    – seagull
    Jan 25 at 21:13











  • It's a primitive form of regex: % is a wildcard meaning any string. In CMD you would use * instead. It's required since wmic will for some reason not allow a comma inside the parameter, while DeviceID contains a comma.

    – harrymc
    Jan 25 at 21:23











  • Got it. So you're using 0,0 as the deviceID. When I use wmic partition the large drive (presumably where all my stuff is) is 0,3; is there any (any) risk of different partitions on the same physical drive having different block sizes?

    – seagull
    Jan 25 at 21:29











  • I don't think so, but don't have a a reference for it.

    – harrymc
    Jan 25 at 21:33











  • Got it. Thanks for your help with this.

    – seagull
    Jan 25 at 21:38



















0














You can pipe the output of fsutil to Select-String and search for 'Bytes Per Sector', 'Bytes pro Sektor', and other language variations to get the line with the info you want, irrespective of line number:



fsutil fsinfo ntfsinfo c: |
select-string 'Bytes Per Sector|Bytes pro Sektor'


You can add additional language strings to the search string using the regular expression 'or' operator (|).



Keith






share|improve this answer
























  • It's looking like this is going to be the only way to do it if the WMI isn't going to co-operate. I'm trying not to do it this way. I know if I include 5 languages the deal-breaker will be the sixth I omitted.

    – seagull
    Jan 27 at 3:40











  • Can you use Get-Culture to determine the language version or output "unrecognized language" if no match is found?

    – Keith Miller
    Jan 27 at 15:21











  • If I knew which languages I was contending with before the fact it wouldn't be so much of an issue. The problem is that this script is going to be GA, so I really can't be writing out seven thousand different versions of the same text string depending on language ID.

    – seagull
    Jan 27 at 19:47



















0














Why not just get them all then select for what you are after.



# Using cmd.exe
wmic partition get BlockSize, StartingOffset, Name, Index

# Results

<#
BlockSize Index Name StartingOffset
512 0 Disk #0, Partition #0 1048576
512 1 Disk #0, Partition #1 472907776
512 2 Disk #0, Partition #2 594542592
512 3 Disk #0, Partition #3 508414656512
512 4 Disk #0, Partition #4 510287413248
512 0 Disk #1, Partition #0 135266304
512 0 Disk #3, Partition #0 135266304
512 0 Disk #2, Partition #0 135266304
#>


$wql = "SELECT Label, Blocksize, Name FROM Win32_Volume WHERE FileSystem='NTFS'"
Get-WmiObject -Query $wql -ComputerName '.' |
Select-Object Label, Blocksize, Name

# Results

<#
Label Blocksize Name
----- --------- ----
4096 \?Volume{bba9420f-c375-409b-977a-b7d4f69b18e6}
Root 4096 C:
4096 \?Volume{184c6e20-4659-4a3a-89e6-c529c69fe26b}
4096 \?Volume{3ebf588c-f842-4c69-9a93-2f241231667e}
Data 4096 D:
SDN 4096 E:
EVO4TB 4096 F:
#>


Update for the OP



The above and below can be done with or without user interaction.



Get-WmiObject -Class Win32_DiskPartition | 
Select-Object -Property Name, BlockSize, Description, BootPartition


or WMIC



 Start-Process -FilePath powershell `
-ArgumentList '-NoExit', 'wmic --% partition get BlockSize, StartingOffset, Name, Index'





share|improve this answer


























  • It is not an interactive script so user intervention cannot be relied on unfortunately

    – seagull
    Jan 27 at 0:10











  • My response was not specific to interactive anything, It could be used with or without any user interaction. Even that WMIC bit can be done via PowerShell directly.

    – postanote
    Jan 27 at 3:56














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1398458%2fget-the-sector-size-of-a-drive-letter-without-using-fsutil%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Here is a command that will get the logical sector size, tested on Windows 7 and
on Windows 10:



wmic partition where "DeviceID like '%Disk #0%#0%'" get BlockSize  | findstr /v BlockSize


Or for the boot partition:



wmic partition where BootPartition=TRUE get BlockSize  | findstr /v BlockSize


Or even:



wmic partition where (BootPartition=TRUE and Type='GPT: System') get BlockSize  | findstr /v BlockSize


The command gets the information for the partition whose DeviceID is like
the specified string. The DeviceID of the first disk will be
"Disk #0, Partition #0", for the second disk it will be
"Disk #1, Partition #0" etc.
The findstr command is required to get rid of the header line.
Elevated permissions are not required for this.



This is the result on my computer:



enter image description here






share|improve this answer


























  • This is great, thank you. I tried "wmic partition > textfile.txt" but I wasn't seeing any disk labels in there. That double-hash-zero-percent is witchcraft, would you be able to explain what it's doing?

    – seagull
    Jan 25 at 21:13











  • It's a primitive form of regex: % is a wildcard meaning any string. In CMD you would use * instead. It's required since wmic will for some reason not allow a comma inside the parameter, while DeviceID contains a comma.

    – harrymc
    Jan 25 at 21:23











  • Got it. So you're using 0,0 as the deviceID. When I use wmic partition the large drive (presumably where all my stuff is) is 0,3; is there any (any) risk of different partitions on the same physical drive having different block sizes?

    – seagull
    Jan 25 at 21:29











  • I don't think so, but don't have a a reference for it.

    – harrymc
    Jan 25 at 21:33











  • Got it. Thanks for your help with this.

    – seagull
    Jan 25 at 21:38
















1














Here is a command that will get the logical sector size, tested on Windows 7 and
on Windows 10:



wmic partition where "DeviceID like '%Disk #0%#0%'" get BlockSize  | findstr /v BlockSize


Or for the boot partition:



wmic partition where BootPartition=TRUE get BlockSize  | findstr /v BlockSize


Or even:



wmic partition where (BootPartition=TRUE and Type='GPT: System') get BlockSize  | findstr /v BlockSize


The command gets the information for the partition whose DeviceID is like
the specified string. The DeviceID of the first disk will be
"Disk #0, Partition #0", for the second disk it will be
"Disk #1, Partition #0" etc.
The findstr command is required to get rid of the header line.
Elevated permissions are not required for this.



This is the result on my computer:



enter image description here






share|improve this answer


























  • This is great, thank you. I tried "wmic partition > textfile.txt" but I wasn't seeing any disk labels in there. That double-hash-zero-percent is witchcraft, would you be able to explain what it's doing?

    – seagull
    Jan 25 at 21:13











  • It's a primitive form of regex: % is a wildcard meaning any string. In CMD you would use * instead. It's required since wmic will for some reason not allow a comma inside the parameter, while DeviceID contains a comma.

    – harrymc
    Jan 25 at 21:23











  • Got it. So you're using 0,0 as the deviceID. When I use wmic partition the large drive (presumably where all my stuff is) is 0,3; is there any (any) risk of different partitions on the same physical drive having different block sizes?

    – seagull
    Jan 25 at 21:29











  • I don't think so, but don't have a a reference for it.

    – harrymc
    Jan 25 at 21:33











  • Got it. Thanks for your help with this.

    – seagull
    Jan 25 at 21:38














1












1








1







Here is a command that will get the logical sector size, tested on Windows 7 and
on Windows 10:



wmic partition where "DeviceID like '%Disk #0%#0%'" get BlockSize  | findstr /v BlockSize


Or for the boot partition:



wmic partition where BootPartition=TRUE get BlockSize  | findstr /v BlockSize


Or even:



wmic partition where (BootPartition=TRUE and Type='GPT: System') get BlockSize  | findstr /v BlockSize


The command gets the information for the partition whose DeviceID is like
the specified string. The DeviceID of the first disk will be
"Disk #0, Partition #0", for the second disk it will be
"Disk #1, Partition #0" etc.
The findstr command is required to get rid of the header line.
Elevated permissions are not required for this.



This is the result on my computer:



enter image description here






share|improve this answer















Here is a command that will get the logical sector size, tested on Windows 7 and
on Windows 10:



wmic partition where "DeviceID like '%Disk #0%#0%'" get BlockSize  | findstr /v BlockSize


Or for the boot partition:



wmic partition where BootPartition=TRUE get BlockSize  | findstr /v BlockSize


Or even:



wmic partition where (BootPartition=TRUE and Type='GPT: System') get BlockSize  | findstr /v BlockSize


The command gets the information for the partition whose DeviceID is like
the specified string. The DeviceID of the first disk will be
"Disk #0, Partition #0", for the second disk it will be
"Disk #1, Partition #0" etc.
The findstr command is required to get rid of the header line.
Elevated permissions are not required for this.



This is the result on my computer:



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 27 at 7:39

























answered Jan 25 at 20:21









harrymcharrymc

264k14273581




264k14273581













  • This is great, thank you. I tried "wmic partition > textfile.txt" but I wasn't seeing any disk labels in there. That double-hash-zero-percent is witchcraft, would you be able to explain what it's doing?

    – seagull
    Jan 25 at 21:13











  • It's a primitive form of regex: % is a wildcard meaning any string. In CMD you would use * instead. It's required since wmic will for some reason not allow a comma inside the parameter, while DeviceID contains a comma.

    – harrymc
    Jan 25 at 21:23











  • Got it. So you're using 0,0 as the deviceID. When I use wmic partition the large drive (presumably where all my stuff is) is 0,3; is there any (any) risk of different partitions on the same physical drive having different block sizes?

    – seagull
    Jan 25 at 21:29











  • I don't think so, but don't have a a reference for it.

    – harrymc
    Jan 25 at 21:33











  • Got it. Thanks for your help with this.

    – seagull
    Jan 25 at 21:38



















  • This is great, thank you. I tried "wmic partition > textfile.txt" but I wasn't seeing any disk labels in there. That double-hash-zero-percent is witchcraft, would you be able to explain what it's doing?

    – seagull
    Jan 25 at 21:13











  • It's a primitive form of regex: % is a wildcard meaning any string. In CMD you would use * instead. It's required since wmic will for some reason not allow a comma inside the parameter, while DeviceID contains a comma.

    – harrymc
    Jan 25 at 21:23











  • Got it. So you're using 0,0 as the deviceID. When I use wmic partition the large drive (presumably where all my stuff is) is 0,3; is there any (any) risk of different partitions on the same physical drive having different block sizes?

    – seagull
    Jan 25 at 21:29











  • I don't think so, but don't have a a reference for it.

    – harrymc
    Jan 25 at 21:33











  • Got it. Thanks for your help with this.

    – seagull
    Jan 25 at 21:38

















This is great, thank you. I tried "wmic partition > textfile.txt" but I wasn't seeing any disk labels in there. That double-hash-zero-percent is witchcraft, would you be able to explain what it's doing?

– seagull
Jan 25 at 21:13





This is great, thank you. I tried "wmic partition > textfile.txt" but I wasn't seeing any disk labels in there. That double-hash-zero-percent is witchcraft, would you be able to explain what it's doing?

– seagull
Jan 25 at 21:13













It's a primitive form of regex: % is a wildcard meaning any string. In CMD you would use * instead. It's required since wmic will for some reason not allow a comma inside the parameter, while DeviceID contains a comma.

– harrymc
Jan 25 at 21:23





It's a primitive form of regex: % is a wildcard meaning any string. In CMD you would use * instead. It's required since wmic will for some reason not allow a comma inside the parameter, while DeviceID contains a comma.

– harrymc
Jan 25 at 21:23













Got it. So you're using 0,0 as the deviceID. When I use wmic partition the large drive (presumably where all my stuff is) is 0,3; is there any (any) risk of different partitions on the same physical drive having different block sizes?

– seagull
Jan 25 at 21:29





Got it. So you're using 0,0 as the deviceID. When I use wmic partition the large drive (presumably where all my stuff is) is 0,3; is there any (any) risk of different partitions on the same physical drive having different block sizes?

– seagull
Jan 25 at 21:29













I don't think so, but don't have a a reference for it.

– harrymc
Jan 25 at 21:33





I don't think so, but don't have a a reference for it.

– harrymc
Jan 25 at 21:33













Got it. Thanks for your help with this.

– seagull
Jan 25 at 21:38





Got it. Thanks for your help with this.

– seagull
Jan 25 at 21:38













0














You can pipe the output of fsutil to Select-String and search for 'Bytes Per Sector', 'Bytes pro Sektor', and other language variations to get the line with the info you want, irrespective of line number:



fsutil fsinfo ntfsinfo c: |
select-string 'Bytes Per Sector|Bytes pro Sektor'


You can add additional language strings to the search string using the regular expression 'or' operator (|).



Keith






share|improve this answer
























  • It's looking like this is going to be the only way to do it if the WMI isn't going to co-operate. I'm trying not to do it this way. I know if I include 5 languages the deal-breaker will be the sixth I omitted.

    – seagull
    Jan 27 at 3:40











  • Can you use Get-Culture to determine the language version or output "unrecognized language" if no match is found?

    – Keith Miller
    Jan 27 at 15:21











  • If I knew which languages I was contending with before the fact it wouldn't be so much of an issue. The problem is that this script is going to be GA, so I really can't be writing out seven thousand different versions of the same text string depending on language ID.

    – seagull
    Jan 27 at 19:47
















0














You can pipe the output of fsutil to Select-String and search for 'Bytes Per Sector', 'Bytes pro Sektor', and other language variations to get the line with the info you want, irrespective of line number:



fsutil fsinfo ntfsinfo c: |
select-string 'Bytes Per Sector|Bytes pro Sektor'


You can add additional language strings to the search string using the regular expression 'or' operator (|).



Keith






share|improve this answer
























  • It's looking like this is going to be the only way to do it if the WMI isn't going to co-operate. I'm trying not to do it this way. I know if I include 5 languages the deal-breaker will be the sixth I omitted.

    – seagull
    Jan 27 at 3:40











  • Can you use Get-Culture to determine the language version or output "unrecognized language" if no match is found?

    – Keith Miller
    Jan 27 at 15:21











  • If I knew which languages I was contending with before the fact it wouldn't be so much of an issue. The problem is that this script is going to be GA, so I really can't be writing out seven thousand different versions of the same text string depending on language ID.

    – seagull
    Jan 27 at 19:47














0












0








0







You can pipe the output of fsutil to Select-String and search for 'Bytes Per Sector', 'Bytes pro Sektor', and other language variations to get the line with the info you want, irrespective of line number:



fsutil fsinfo ntfsinfo c: |
select-string 'Bytes Per Sector|Bytes pro Sektor'


You can add additional language strings to the search string using the regular expression 'or' operator (|).



Keith






share|improve this answer













You can pipe the output of fsutil to Select-String and search for 'Bytes Per Sector', 'Bytes pro Sektor', and other language variations to get the line with the info you want, irrespective of line number:



fsutil fsinfo ntfsinfo c: |
select-string 'Bytes Per Sector|Bytes pro Sektor'


You can add additional language strings to the search string using the regular expression 'or' operator (|).



Keith







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 27 at 3:33









Keith MillerKeith Miller

262




262













  • It's looking like this is going to be the only way to do it if the WMI isn't going to co-operate. I'm trying not to do it this way. I know if I include 5 languages the deal-breaker will be the sixth I omitted.

    – seagull
    Jan 27 at 3:40











  • Can you use Get-Culture to determine the language version or output "unrecognized language" if no match is found?

    – Keith Miller
    Jan 27 at 15:21











  • If I knew which languages I was contending with before the fact it wouldn't be so much of an issue. The problem is that this script is going to be GA, so I really can't be writing out seven thousand different versions of the same text string depending on language ID.

    – seagull
    Jan 27 at 19:47



















  • It's looking like this is going to be the only way to do it if the WMI isn't going to co-operate. I'm trying not to do it this way. I know if I include 5 languages the deal-breaker will be the sixth I omitted.

    – seagull
    Jan 27 at 3:40











  • Can you use Get-Culture to determine the language version or output "unrecognized language" if no match is found?

    – Keith Miller
    Jan 27 at 15:21











  • If I knew which languages I was contending with before the fact it wouldn't be so much of an issue. The problem is that this script is going to be GA, so I really can't be writing out seven thousand different versions of the same text string depending on language ID.

    – seagull
    Jan 27 at 19:47

















It's looking like this is going to be the only way to do it if the WMI isn't going to co-operate. I'm trying not to do it this way. I know if I include 5 languages the deal-breaker will be the sixth I omitted.

– seagull
Jan 27 at 3:40





It's looking like this is going to be the only way to do it if the WMI isn't going to co-operate. I'm trying not to do it this way. I know if I include 5 languages the deal-breaker will be the sixth I omitted.

– seagull
Jan 27 at 3:40













Can you use Get-Culture to determine the language version or output "unrecognized language" if no match is found?

– Keith Miller
Jan 27 at 15:21





Can you use Get-Culture to determine the language version or output "unrecognized language" if no match is found?

– Keith Miller
Jan 27 at 15:21













If I knew which languages I was contending with before the fact it wouldn't be so much of an issue. The problem is that this script is going to be GA, so I really can't be writing out seven thousand different versions of the same text string depending on language ID.

– seagull
Jan 27 at 19:47





If I knew which languages I was contending with before the fact it wouldn't be so much of an issue. The problem is that this script is going to be GA, so I really can't be writing out seven thousand different versions of the same text string depending on language ID.

– seagull
Jan 27 at 19:47











0














Why not just get them all then select for what you are after.



# Using cmd.exe
wmic partition get BlockSize, StartingOffset, Name, Index

# Results

<#
BlockSize Index Name StartingOffset
512 0 Disk #0, Partition #0 1048576
512 1 Disk #0, Partition #1 472907776
512 2 Disk #0, Partition #2 594542592
512 3 Disk #0, Partition #3 508414656512
512 4 Disk #0, Partition #4 510287413248
512 0 Disk #1, Partition #0 135266304
512 0 Disk #3, Partition #0 135266304
512 0 Disk #2, Partition #0 135266304
#>


$wql = "SELECT Label, Blocksize, Name FROM Win32_Volume WHERE FileSystem='NTFS'"
Get-WmiObject -Query $wql -ComputerName '.' |
Select-Object Label, Blocksize, Name

# Results

<#
Label Blocksize Name
----- --------- ----
4096 \?Volume{bba9420f-c375-409b-977a-b7d4f69b18e6}
Root 4096 C:
4096 \?Volume{184c6e20-4659-4a3a-89e6-c529c69fe26b}
4096 \?Volume{3ebf588c-f842-4c69-9a93-2f241231667e}
Data 4096 D:
SDN 4096 E:
EVO4TB 4096 F:
#>


Update for the OP



The above and below can be done with or without user interaction.



Get-WmiObject -Class Win32_DiskPartition | 
Select-Object -Property Name, BlockSize, Description, BootPartition


or WMIC



 Start-Process -FilePath powershell `
-ArgumentList '-NoExit', 'wmic --% partition get BlockSize, StartingOffset, Name, Index'





share|improve this answer


























  • It is not an interactive script so user intervention cannot be relied on unfortunately

    – seagull
    Jan 27 at 0:10











  • My response was not specific to interactive anything, It could be used with or without any user interaction. Even that WMIC bit can be done via PowerShell directly.

    – postanote
    Jan 27 at 3:56


















0














Why not just get them all then select for what you are after.



# Using cmd.exe
wmic partition get BlockSize, StartingOffset, Name, Index

# Results

<#
BlockSize Index Name StartingOffset
512 0 Disk #0, Partition #0 1048576
512 1 Disk #0, Partition #1 472907776
512 2 Disk #0, Partition #2 594542592
512 3 Disk #0, Partition #3 508414656512
512 4 Disk #0, Partition #4 510287413248
512 0 Disk #1, Partition #0 135266304
512 0 Disk #3, Partition #0 135266304
512 0 Disk #2, Partition #0 135266304
#>


$wql = "SELECT Label, Blocksize, Name FROM Win32_Volume WHERE FileSystem='NTFS'"
Get-WmiObject -Query $wql -ComputerName '.' |
Select-Object Label, Blocksize, Name

# Results

<#
Label Blocksize Name
----- --------- ----
4096 \?Volume{bba9420f-c375-409b-977a-b7d4f69b18e6}
Root 4096 C:
4096 \?Volume{184c6e20-4659-4a3a-89e6-c529c69fe26b}
4096 \?Volume{3ebf588c-f842-4c69-9a93-2f241231667e}
Data 4096 D:
SDN 4096 E:
EVO4TB 4096 F:
#>


Update for the OP



The above and below can be done with or without user interaction.



Get-WmiObject -Class Win32_DiskPartition | 
Select-Object -Property Name, BlockSize, Description, BootPartition


or WMIC



 Start-Process -FilePath powershell `
-ArgumentList '-NoExit', 'wmic --% partition get BlockSize, StartingOffset, Name, Index'





share|improve this answer


























  • It is not an interactive script so user intervention cannot be relied on unfortunately

    – seagull
    Jan 27 at 0:10











  • My response was not specific to interactive anything, It could be used with or without any user interaction. Even that WMIC bit can be done via PowerShell directly.

    – postanote
    Jan 27 at 3:56
















0












0








0







Why not just get them all then select for what you are after.



# Using cmd.exe
wmic partition get BlockSize, StartingOffset, Name, Index

# Results

<#
BlockSize Index Name StartingOffset
512 0 Disk #0, Partition #0 1048576
512 1 Disk #0, Partition #1 472907776
512 2 Disk #0, Partition #2 594542592
512 3 Disk #0, Partition #3 508414656512
512 4 Disk #0, Partition #4 510287413248
512 0 Disk #1, Partition #0 135266304
512 0 Disk #3, Partition #0 135266304
512 0 Disk #2, Partition #0 135266304
#>


$wql = "SELECT Label, Blocksize, Name FROM Win32_Volume WHERE FileSystem='NTFS'"
Get-WmiObject -Query $wql -ComputerName '.' |
Select-Object Label, Blocksize, Name

# Results

<#
Label Blocksize Name
----- --------- ----
4096 \?Volume{bba9420f-c375-409b-977a-b7d4f69b18e6}
Root 4096 C:
4096 \?Volume{184c6e20-4659-4a3a-89e6-c529c69fe26b}
4096 \?Volume{3ebf588c-f842-4c69-9a93-2f241231667e}
Data 4096 D:
SDN 4096 E:
EVO4TB 4096 F:
#>


Update for the OP



The above and below can be done with or without user interaction.



Get-WmiObject -Class Win32_DiskPartition | 
Select-Object -Property Name, BlockSize, Description, BootPartition


or WMIC



 Start-Process -FilePath powershell `
-ArgumentList '-NoExit', 'wmic --% partition get BlockSize, StartingOffset, Name, Index'





share|improve this answer















Why not just get them all then select for what you are after.



# Using cmd.exe
wmic partition get BlockSize, StartingOffset, Name, Index

# Results

<#
BlockSize Index Name StartingOffset
512 0 Disk #0, Partition #0 1048576
512 1 Disk #0, Partition #1 472907776
512 2 Disk #0, Partition #2 594542592
512 3 Disk #0, Partition #3 508414656512
512 4 Disk #0, Partition #4 510287413248
512 0 Disk #1, Partition #0 135266304
512 0 Disk #3, Partition #0 135266304
512 0 Disk #2, Partition #0 135266304
#>


$wql = "SELECT Label, Blocksize, Name FROM Win32_Volume WHERE FileSystem='NTFS'"
Get-WmiObject -Query $wql -ComputerName '.' |
Select-Object Label, Blocksize, Name

# Results

<#
Label Blocksize Name
----- --------- ----
4096 \?Volume{bba9420f-c375-409b-977a-b7d4f69b18e6}
Root 4096 C:
4096 \?Volume{184c6e20-4659-4a3a-89e6-c529c69fe26b}
4096 \?Volume{3ebf588c-f842-4c69-9a93-2f241231667e}
Data 4096 D:
SDN 4096 E:
EVO4TB 4096 F:
#>


Update for the OP



The above and below can be done with or without user interaction.



Get-WmiObject -Class Win32_DiskPartition | 
Select-Object -Property Name, BlockSize, Description, BootPartition


or WMIC



 Start-Process -FilePath powershell `
-ArgumentList '-NoExit', 'wmic --% partition get BlockSize, StartingOffset, Name, Index'






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 27 at 4:01

























answered Jan 26 at 4:03









postanotepostanote

1,133133




1,133133













  • It is not an interactive script so user intervention cannot be relied on unfortunately

    – seagull
    Jan 27 at 0:10











  • My response was not specific to interactive anything, It could be used with or without any user interaction. Even that WMIC bit can be done via PowerShell directly.

    – postanote
    Jan 27 at 3:56





















  • It is not an interactive script so user intervention cannot be relied on unfortunately

    – seagull
    Jan 27 at 0:10











  • My response was not specific to interactive anything, It could be used with or without any user interaction. Even that WMIC bit can be done via PowerShell directly.

    – postanote
    Jan 27 at 3:56



















It is not an interactive script so user intervention cannot be relied on unfortunately

– seagull
Jan 27 at 0:10





It is not an interactive script so user intervention cannot be relied on unfortunately

– seagull
Jan 27 at 0:10













My response was not specific to interactive anything, It could be used with or without any user interaction. Even that WMIC bit can be done via PowerShell directly.

– postanote
Jan 27 at 3:56







My response was not specific to interactive anything, It could be used with or without any user interaction. Even that WMIC bit can be done via PowerShell directly.

– postanote
Jan 27 at 3:56




















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1398458%2fget-the-sector-size-of-a-drive-letter-without-using-fsutil%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]