Saturday, 10 September 2016

Disk block size with Powershell

Recently I was working on documenting SQL Servers using the SQL Powerdoc which is from codeplex. One of the interesting thing which I saw was in the output was about allocation of storage size for SQL Servers.

As a best practice storage allocation size should be 64 KB. Please refer this Microsoft article for more information about this, click here

So now the next question is how do I check my disk block size?

Let’s do the PowerShell way, here is the script which you can use to check the block size

Get-WmiObject -Class Win32_volume -Filter "FileSystem='NTFS'" | Select-Object Name, Lable, BlockSize | Format-Table -AutoSize

sample output


Now the question is how do I do it for all the SQL servers in my network?

PowerShell makes things more simple. First get the server list for which you’re going to get the block size and save it in a text file. Now open PowerShell and run the below script

#Inside the below quotes provide the complete path with the server list file name#
$ServerList = Get-Content 'C:\ServerList.txt' 
Get-WmiObject -Class Win32_volume -Filter "FileSystem='NTFS'" -ComputerName $ServerList | Select-Object PSComputerName, Name, Lable, BlockSize | Format-Table -AutoSize

sample output


Cheers,
Naveen

No comments:

Post a Comment

Please share your thoughts