Answered PowerShell CREATE A SELF-SIGNED CERTIFICATE

  • 11 September 2011 14:43
     
      Memiliki Kode

    Sorry but stupid question time. I am definitely doing something wrong and don't have a clue what it is.

    I created a simple PowerShell script and have tested it with the PowerShell scripting options set to Set-ExecutionPolicy unrestricted and it works just fine. Now I would like to self sign it so I can change the Policy to All Signed. The problem I am having is running the commands from the Get-Help about_signing CREATE A SELF-SIGNED CERTIFICATE section.

     

        Note: You can copy or type the commands exactly as they appear.
    No substitutions are necessary, although you can change the
    certificate name.

    makecert -n "CN=PowerShell Local Certificate Root" -a sha1 `
    -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer `
    -ss Root -sr localMachine

    If I copy and paste it into the command window the first line is successful. The second line fails with the message '-eku' is not recognized as an internal or external command, Which makes sense.

    If  I put it all on one line I get the error message too many parameters.

    How do you run these commands?

    Any help is appreciated

    Thanks

    Windows 7 64bit

    Microsoft Windows SDK for Windows 7 (7.0.7600.16385.40715)
    http://technet.microsoft.com/en-us/library/dd347649.aspx

     



Semua Balasan

  • 11 September 2011 14:59
    Moderator
     
     

     

     

    If I copy and paste it into the command window the first line is successful. The second line fails with the message '-eku' is not recognized as an internal or external command, Which makes sense.


    Actually, that doesn't make sense.  That last character on the first line should be a backtick, which indicates a line continuation.

    That you're getting that error on the second line indicates it's not recognizing the second line as a continuation of the first line.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
  • 11 September 2011 16:26
     
     

    Very strange

    Here is what I get from a copy and paste

    it is seeing each line as a complete command

    C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin>makecert -n "CN=PowerShell Local Certificate Root"
    -a sha1 `
    Succeeded

    C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin>-eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer `
    '-eku' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin>makecert -n "CN=PowerShell Local Certificate Root"
    -a sha1 `
    Succeeded

    C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin>                -eku 1.3.6.1.5.5.7.3.3 -r -sv root.
    pvk root.cer `
    '-eku' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin>                -ss Root -sr localMachine
    '-ss' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin>

     

     

     

     

     

  • 11 September 2011 16:34
     
     Jawab

    Are you pasting into a DOS Window?

    Yes.  That is why.

     

     


    jv
  • 12 Oktober 2011 16:54
     
     

    Yes you are correct that was what I was doing.

    Thwack!

    Stupid me Live and Learn

     

    Thanks got it all figured out and working now.

  • 02 Desember 2011 23:14
     
     

    When I run this it says the term makecert is not a recognized as the name of a cmdlet

     


    foxjazz
  • 31 Mei 2012 6:54
     
     

    Most likely you don't have the Windows SDK installed. Windows SDK holds the required file MakeCert.exe.

    You can download it here: http://go.microsoft.com/fwlink/?linkid=84091

    Kind regards,

    Jack

  • 21 Agustus 2012 21:06
     
     

    I am now in the same mess. Windows 7 Professional 64bit.  I wanted to run a simple Powershell and needed certificate.  I downloaded Windows SDK and for some reason I needed Windows Net 4.0 with all its frameworks.  I found 2 versions of makecert.exe.  Not surprising.  I ended back in Powershell and tried

    Set-Location C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64
     makecert -n "CN=PowerShell Local Certificate Root" -a sha1 `
                    -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer `
                    -ss Root -sr localMachine

    Results:The term 'makecert' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, o
    r if a path was included, verify that the path is correct and try again.
    At line:2 char:10
    +  makecert <<<<  -n "CN=PowerShell Local Certificate Root" -a sha1 `
        + CategoryInfo          : ObjectNotFound: (makecert:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

  • 21 Agustus 2012 21:54
    Moderator
     
     

    Hi,

    This question is already marked as answered. Please start a new question.

    Bill

  • 24 Desember 2012 19:42
     
     

    Try this.

    .\makecert.exe -n "CN=PowerShell Local Certificate Root" -a sha1 -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer -ss Root -sr localMachine

  • 24 Desember 2012 19:44
     
     

    Try this....

    .\makecert.exe -n "CN=PowerShell Local Certificate Root" -a sha1 `
                    -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer `
                    -ss Root -sr localMachine