Windows 10: How to sign Powershell profile w/ self-signed certificate?

Discus and support How to sign Powershell profile w/ self-signed certificate? in Windows 10 Support to solve the problem; POWERSHELL ONLY SOLUTION: The following is a powershell-only solution which will not require the installation of extra software/tools/features (at... Discussion in 'Windows 10 Support' started by EdTittel, Apr 4, 2018.

  1. How to sign Powershell profile w/ self-signed certificate?


    POWERSHELL ONLY SOLUTION:

    The following is a powershell-only solution which will not require the installation of extra software/tools/features (at least on Windows 10):

    #Open up a Powershell window—with Admin privileges—and run the following to create the self-signed certificate and save it to the PS variable of your choice. Below, the naming distinction mycert is used. I recommend that or just copy/paste the code.
    Code: $mycert = New-SelfSignedCertificate -Subject "CN=PowerShell signing example" ` -KeyAlgorithm RSA -KeyLength 2048 -Type CodeSigningCert ` -CertStoreLocation Cert:\LocalMachine\My\ [/quote] #Next, to verify the certificate was created, simply type the variable you just created.
    #For example, the above would be $cert
    #Hit enter, and the thing should print out a thumbprint to the screen.

    #Now, with that outta the way, you need to move the certificate you just created the root cert store on your machine.
    #To do this, run the following command (take note of the variable name; i.e. use what you used above):
    Code: Move-Item "Cert:\LocalMachine\My\$($mycert.Thumbprint)" Cert:\LocalMachine\Root[/quote] #Finally, with that out of the way, you can sign your script with the following command

    Code: set-AuthenticodeSignature C:\Path\To\Script\test.ps1 $mycert[/quote]

    Once you run that command, you should receive output on the console displaying the successful signing.

    Incidentally, I had tried this route before but kept failing because I didn't move the certificate to the root cert store. Now I know.

    In the end, I don't feel better about this compared to having just changed the execution-policy.

    For those interested in the guide referenced for this method, please visit this link.

    For those interested in the guide referenced for the first method (on page 1), click this link.

    P.S. - I knew the code I used looked familiar, and I eventually wound up finding (piece by piece) the entire guide on another site.

    P.P.S. - We shouldn't be required to do all of this just to get a few permanent aliases in Powershell.
     
    That Random Guy, Apr 11, 2018
    #16

  2. That is one way to do it! *Smile

    I have been looking into this, but I'm still not quite convinced. The descriptions on the interwebs are a bit around the bush when it comes to explaining things.

    Let's work on this further.
     
    slicendice, Apr 11, 2018
    #17
Thema:

How to sign Powershell profile w/ self-signed certificate?

Loading...
  1. How to sign Powershell profile w/ self-signed certificate? - Similar Threads - sign Powershell profile

  2. RDP Self Signed Certificate 3389 Remote Desktop Protocol

    in Windows 10 Gaming
    RDP Self Signed Certificate 3389 Remote Desktop Protocol: Tenable Nessus Scans showing self signed cert used for RDP on port 3389.Done my due diligence - 1. Cert is located in certlm.msc > Remote Desktop2. You can create a custom template and generate a cert to be used for RDP and put in that folder3. Deleting the self signed - it...
  3. RDP Self Signed Certificate 3389 Remote Desktop Protocol

    in Windows 10 Software and Apps
    RDP Self Signed Certificate 3389 Remote Desktop Protocol: Tenable Nessus Scans showing self signed cert used for RDP on port 3389.Done my due diligence - 1. Cert is located in certlm.msc > Remote Desktop2. You can create a custom template and generate a cert to be used for RDP and put in that folder3. Deleting the self signed - it...
  4. An invalid [self-signed] CA certificate exists on Windows 10 Pro, but...

    in AntiVirus, Firewalls and System Security
    An invalid [self-signed] CA certificate exists on Windows 10 Pro, but...: Statement of the Problem: An invalid self-signed CA certificate which all browsers says it's using, can't be found by standard Windows tools so it can be removed.Background: I have a small self-hosted environment in Docker on Windows 10. I've identified a bogus CA certificate...
  5. Self signed certificate used to expire standalone media MECM

    in Windows 10 Software and Apps
    Self signed certificate used to expire standalone media MECM: Good evening folks,I'm currently exploring making a USB software stick created with MECM more secure by password protecting it and assigning the self signed certificate during the task sequence standalone media creation which lets it expire. I've searched quite a bit and...
  6. Self signed certificate used to expire standalone media MECM

    in Windows 10 Customization
    Self signed certificate used to expire standalone media MECM: Good evening folks,I'm currently exploring making a USB software stick created with MECM more secure by password protecting it and assigning the self signed certificate during the task sequence standalone media creation which lets it expire. I've searched quite a bit and...
  7. Self signed certificate used to expire standalone media MECM

    in Windows 10 Gaming
    Self signed certificate used to expire standalone media MECM: Good evening folks,I'm currently exploring making a USB software stick created with MECM more secure by password protecting it and assigning the self signed certificate during the task sequence standalone media creation which lets it expire. I've searched quite a bit and...
  8. Ftps with self-signed certificate. Remote access issue

    in Windows 10 Network and Sharing
    Ftps with self-signed certificate. Remote access issue: Hi,Sorry I’m not very experienced with this topic. As the title suggests, I created a self signed certificate and set up a ftp over ssl with port 21 explicit. Than forwarded the 21 port in my router and assigned an external one. I’m able to connect to it locally, with the pc...
  9. Secure Credentials with Self-Signed Certificates for PowerShell Script

    in Windows 10 News
    Secure Credentials with Self-Signed Certificates for PowerShell Script: Hello everyone, I’m Preston K. Parsard, specializing in Platforms, Azure Infrastructure and Automation topics, and I’d like to share some insights for securing PowerShell credentials using certificates. This post is based on a recent customer project, but we’ll also wrap a...
  10. Self-Signed Certificates no longer working since update

    in Windows 10 Support
    Self-Signed Certificates no longer working since update: Morning all, annoyingly Windows decided to update itself over the weekend and rebooted my PC. This also happened with a few other work PCs and left users unable to login for an hour while it forced the update on us. Luckily we only have a handful of Win 10 PCs and decided...