Following PowerShell script allows to change write caching policy (enable or disable) for multiple disk devices remotely and for multiple servers. I have not found ready to go PowerShell cmdlet from Microsoft or MSFT Disk property which allowed to change write-caching policy for disks in easy way without manual human operation clicking with mouse in device/or disk manager. Just assume how it is convenient for multiple servers and disks.

At the same time Microsoft has developed command line utility called dskcache.exe and utility was sucessfully tested with Windows Server 2000-2016. PowerShell script will use this utility.

Prerequsites

1. Download dskcache.exe utility from https://support.microsoft.com/kb/811392 (Product: Windows 2000, Platform x86)
2. Unpack and install it into the same file directory as PowerShell script ChangeWriteCaching.ps1
3. Local Administrator rights for local and remote server.
4. Enabled PowerShell remoting. For Windows 2012+ Windows PowerShell remoting is enabled by default.
For earlier Windows versions you might have it disabled check URL: https://technet.microsoft.com/en-us/magazine/ff700227.aspx

Running script

Script usage option 1Enable write caching on the Disk 1, Disk 2, Disk 3, ..., Disk 14 and on selected servers server1, server2, ..., server6

PowerShell
Edit|Remove
.\ChangeWriteCaching.ps1 -Disks (1..14) -WriteCache $true -Servers server1,server2,server3,server4,server5,server6
Script usage option 2Disable write caching on the Disk 1, Disk 2, Disk 6, Disk 10, Disk 15 and on selected servers server1,server2,...,server6
PowerShell
Edit|Remove
.\ChangeWriteCaching.ps1 -Disks (1,2,6,10,15) -WriteCache $false -Servers server1,server2,server3,server4,server5,server6
Script usage option 3: Disable write caching using CSV file Servers.csv as input with server list
PowerShell
Edit|Remove
.\ChangeWriteCaching.ps1 -Disks (1..14) -WriteCache $false -Servers (Import-Csv Servers.csv).servers
where Servers.csv file contains target server list to work with
Script usage option 4: Enable write caching on the Disk 1, Disk 2, Disk 6, Disk 10, Disk 15 on single server server1
PowerShell
Edit|Remove
.\ChangeWriteCaching.ps1 -Disks (1..14) -WriteCache $true -Servers server1

Results

Sample output (abridged for brevity):

Note: For some storage controllers (like RAID) changing write caching policy may have no effect because of caching policy is being managed by storage controller settings.