Wednesday 6 September 2017

Disk block size with PowerShell

Recently while working with one of the customer engagement, we had a discussion about recommendation on disk block size for SQL Server.

Do you need to worry about disk block size?
I would suggest you to read below articles for getting better understanding on this topic

Disk Partition Alignment Best Practices for SQL Server
WHAT IS SQL SERVER’S IO BLOCK SIZE?

Post discussion, the next question was how do we check the disk block size for a given server?
You can do it from command line using FSutil utility. But let's do it with PowerShell. Here is the code which I ran to get the block size details

Get-CimInstance -ClassName Win32_Volume -Filter "FileSystem='NTFS'" | Select-Object Name, Label, BlockSize | Format-Table -AutoSize

OR

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

Click here, if you are confused whether you should use Get-CimInstance or Get-WmiObject  ☺









After showing it on one server, then customer gave me a list of SQL Servers on which we should get the similar details.

PowerShell makes things more simple. I got the server list in a text file and saved it on my client machine desktop. Open PowerShell and run the below code.

$ServerList = Get-Content 'C:\Users\user1\Desktop\ServerList.txt' 
Get-WmiObject -Class Win32_volume -Filter "FileSystem='NTFS'" -ComputerName $ServerList | Select-Object PSComputerName, Name, Lable, BlockSize | Format-Table -AutoSize

Here is the sample output. Just make sure you replace 'C:\Users\user1\Desktop\ServerList.txt' path as per your requirement.











Hope this helps

Cheers,
Naveen

4 comments:

  1. How can be provide access for more than 1 server on sql using Powershell? Could you please help

    ReplyDelete
  2. The best casinos in Las Vegas, NV - DRMCD
    Most gamblers in Las 계룡 출장샵 Vegas 원주 출장샵 may not know anything 김해 출장안마 about slot machines or table games, but one thing 삼척 출장안마 is clear: Las Vegas casinos 태백 출장마사지 are very good at it.

    ReplyDelete