Search code examples
asp.netpowershelliismachine.config

Generate Machine Key using power Shell - Unrecognized Command


I am trying to generate a machine key to place in my web configs, but its saying it is not recognized. I have already read the following question and use the same commands without success Generate Machine Key. Please check what am i doing:

I took the Powershell Script from microsoft site, then executed the commands below:

PS C:\> C:\Users\myuser\Desktop\Docs\KeyGeneration\machinekey.ps1

Then

PS C:\> Generate-MachineKey -validationAlgorithm SHA1

It says that:

The term 'Generate-MachineKey' is not recognized as the name of a cmdlet, function, script file

Solution

  • Try "dot sourcing" the running of the script, by placing a period and then a space before the script

    PS C:> . C:\Users\myuser\Desktop\Docs\KeyGeneration\machinekey.ps1