In the previous post we have gathered a list of workstations that required their Microsoft .NET Framework to be downgraded. Let’s downgrade them remotely using the Windows Management Instrumentation Command-line (WMIC).
WMIC: Getting list of installed software remotely
To get a list of all installed software on a remote computer, we can use the Windows Management Instrumentation Command-line (WMIC) – a command-line and scripting interface that simplifies the use of Windows Management Instrumentation (WMI) and systems managed through WMI.
To enter the console, type in wmic in cmd.exe or PowerShell:
Then, we could execute the following command to list all software installed on the remote machine:
/node:”computername” product get name, version
If we are only interested in a particular piece of software we can filter this list by using LIKE clause. This is a great post on using it.
/node:”computername” product where “Name like ‘%NET%’” get Name, version
WMIC: Uninstalling software remotely
/node:”computername” product where name=”Microsoft .NET Framework 4.5.2″ call uninstall
Preparing the installer
Installing our desired .NET version remotely is slightly more difficult, because when we call install method in wmic, it expects a suitable *.msi to be present on the remote machine local drive. While it’s relatively simple to copy the installer files to the remote machine, getting the offline .NET installer to work directly is not a trivial task.
ITNINJA will help us with that through this magnificent article.
I would recommend you to follow steps listed in the resource above, but in essence, we need to unpack the .NET 4.5.1 installer *.exe file, then patch the original MSI installer, so that it allows us to run it directly. I will only describe one thing that isn’t mentioned in the article. For our purposes within InstEd software we still have to modify the CA_BlockDirectInstall (as the article suggests):
But instead of just saving the transform as the article above suggests, we first save the transforms and then save the modified installer into the *.msi file by selecting Save Transformed option:
WMIC: Installing software remotely
Save the *.msi into the folder with extracted installer contents and copy that folder to remote machine. Then, call the install method from wmic:
wmic:root\cli>/node:”computername” product call install true,””,”C:\DotNet\dotnet.msi”
Let’s check that we have indeed installed the desired software by getting the list of installed products again:
WMIC: Restarting machines remotely
If the applications making use of .NET framework require a restart (they do in our case) you can also restart the machine using WMIC:
wmic:root\cli>/node:”computername” os where Primary=’TRUE’ reboot
Steps above could of course be easily automated and I may get some spare time in future to put together an appropriate script