I'm writing an implementation plan involving changing ASP.NET machine key settings for .NET 4.0 on servers that are running IIS 7.0.
I'd prefer to have the setting changed via IIS Manager.
On my local machine, running IIS 7.5 this is easy. Go into IIS Manager, and in the Actions pane on the right hand right is a command Change .NET Framework Version. I can change this between .NET 2.0 and .NET 4.0, and this changes which machine level web.config I am editing when I change the machine key from the IIS Manager home page.
However IIS 7.0 does not have the Change .NET Framework Version command anywhere I can see. I therefore can't see any way for the .NET 4.0 machine key setting to be changed, other than manually editing C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
So two questions
- Is there an equivalent to the IIS Manager 7.5 command "Change .NET Framework Version" in IIS Manager 7.0?
- Is there any other way to set the machine key settings in
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
without manually editing the file on an IIS 7.0 machine?
Best Answer
It should be possible to script such a process, I would probably start with PSH as it has inbuilt XML support and access to .NET (useful for generating new keys if they are being specified).
But the first thing is to get the list of virtual directories at which to start. This is mostly easily done with
appcmd
:At this point
$vdirs
is an array of folders mapped to IIS.Within each of these search for
web.config
files:Which is an array of the full path names of the
web.config
files. At this point you can use PowerShell's XML support to examine or update any part of the file you like