4

I have a server which we are using for Batch processing.

I can login to the server with svc_account and run powershell -f file.ps1 and it runs fine in either version 2 or 3 by the following -

powershell -Version 2 -f file.ps1
powershell -f file.ps1

If I attempt to run it through our batch processor I get the following message

Version v4.0.30319 of the .NET Framework is not installed and it is required to run version 3 of Windows PowerShell.

This error occurs regardless of if I get my batch processor to run as v3 or v2 of powershell.

Thing is, .NET is installed. 3.5, 4.0 and 4.5 all exist on this server so it's something with the account login that it's for some reason not recognizing that .NET is installed.

6
  • Check for the registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework] "InstallRoot"="C:\Windows\\Microsoft.NET\Framework64\"
    – krisFR
    May 29 '15 at 23:03
  • 1
    does it run fine if the pull path to powershell.exe is specified? May 29 '15 at 23:20
  • @krisFR that key is missing/not there but the InstallRoot Key can be found under v4\Client, v4\Full, etc. I checked a working server and the registry under [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework] is the same in both servers
    – whoisearth
    May 30 '15 at 15:16
  • @user2320464 full path for powershell gives the same error. Doesn't matter if I use 32 bit or 64 bit, but for example calling %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Write-Host "Hello!" still generates the error message.
    – whoisearth
    May 30 '15 at 15:18
  • Are you using PS remoting? Jun 2 '15 at 20:17
1

Add this key and try running it again:

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework] "InstallRoot"="C:\\Windows\\Microsoft.NET\\Framework64\\"

3
  • 2
    I have the same error except it's complaining about .NET Frameworks 4.6.00081. Unfortunately, this registry setting is already set to this value. Oct 19 '15 at 20:40
  • 1
    This doesn't do it. the registry is correct and nothing seems to be wrong with the install. issue seems to be with the user profiles specifically when being called as remote logins.
    – whoisearth
    Oct 22 '15 at 0:21
  • 1
    @whoisearth I ran into this issue when running PowerShell in Windows Sandbox, the new Windows feature which runs a clean install of Windows and then logs to it remotely, so I think what you allude it is the issue here as well. Can you elaborate on what it was that you meant with user profiles and remote logins? Did you find a solution? Jun 21 '19 at 7:08
0

We were running powershell on the .NET framework version 4 (ala:

https://stackoverflow.com/q/2094694

) this involved using an activation configuration file

<startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> 

and

set COMPLUS_ApplicationMigrationRuntimeActivationConfigPath = %~dp0

The important part in our case was that we were requesting framework version 4.6.1 and we only had 4.5 installed.

The error message is clearly inadequate because the framework version was not the issue. But because this question is the first hit you get when you search that error message this answer will hopefully prove useful to someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.