Increase VMBus buffer sizes to increase network throughput to guest VMs – PowerShell Edition
In this article the title is explained. It also explains how to set it manually on all VM’s that you have. As lazy admin as I am I created a PowerShell script that can be ran manually when configuring/installing a VM or you can set is as shutdown script so every time a VM shuts down it is checked if a new “Microsoft Virtual Machine Bus Network Adapter” has been added to the VM.
| RSBufferSize.ps1 |
| if (Get-ItemProperty -Name “ReceiveBufferSize” -path “hklm:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\*” -erroraction silentlycontinue | where {$_.DriverDesc -eq “Microsoft Virtual Machine Bus Network Adapter”}) {“Registry key ReceiveBufferSize already exists”} else {Get-ItemProperty -Name “DriverDesc” -path “hklm:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\*” -erroraction silentlycontinue | where {$_.DriverDesc -eq “Microsoft Virtual Machine Bus Network Adapter”} | new-itemproperty -name ReceiveBufferSize -value 2048 -propertyType dword -erroraction silentlycontinue}if (Get-ItemProperty -Name “SendBufferSize” -path “hklm:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\*” -erroraction silentlycontinue | where {$_.DriverDesc -eq “Microsoft Virtual Machine Bus Network Adapter”})
{“Registry key SendBufferSize already exists”} else {Get-ItemProperty -Name “DriverDesc” -path “hklm:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\*” -erroraction silentlycontinue | where {$_.DriverDesc -eq “Microsoft Virtual Machine Bus Network Adapter”} | new-itemproperty -name SendBufferSize -value 2048 -propertyType dword -erroraction silentlycontinue} |
Having written the script we want to use it! At this point you have a choice to make; there are two options:
1. Sign the script (you’ll need a Code Signing certificate and private key, then: $cert = @(gci cert:\currentuser\CodeSigningCert)[0]; Set-AuthenticodeSignature RSBufferSize.ps1$cert);
2. Set the script execution policy to Unrestricted (Set-ExecutionPolicy -ExecutionPolicy Unrestricted)
I strongly recommend option 1 for security, but in a lab or low security environment (i.e. you WANT your hosts to be compromised) option 2 might be acceptable.
Finally, you need to configure Group Policy or Local Policy for the host to have a Startup Script. You’ll find these settings under Computer Settings > Windows Settings > Scripts (Startup/Shutdown):

PowerShell Scripts tab (not the default Scripts tab):
Add a new script and set the script path to your saved file:

Why a Startup script? I tried a shutdown script but it didn’t work
Reboot required to make settings effective!
It’s worth noting that scripts executed by Group Policy do not need to be signed – they bypass the script execution policy settings. Nevertheless you’re going to want to sign it so that:
- If someone changes the script you will know when you run it manually;
- You can test the script;
- You can use it for reasons other than shutting down a host.
That’s all that needs to be done – now it’s testing time. The script is included in the text so you can just copy it, save it, sign it and test it.


Recent Comments