Windows 10: Secure Credentials with Self-Signed Certificates for PowerShell Script

Discus and support Secure Credentials with Self-Signed Certificates for PowerShell Script in Windows 10 News to solve the problem; Hello everyone, I’m Preston K. Parsard, specializing in Platforms, Azure Infrastructure and Automation topics, and I’d like to share some insights for... Discussion in 'Windows 10 News' started by Brink, Jan 15, 2019.

  1. Brink Win User

    Secure Credentials with Self-Signed Certificates for PowerShell Script


    Read more: Secure Credentials with Self-Signed Certificates for PowerShell Scripts | Ask Premier Field Engineering (PFE) Platforms

    :)
     
    Brink, Jan 15, 2019
    #1

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


    I currently have my execution-policy set to AllSigned. I don't want to change it or bypass that restriction.

    When I created my profile script--or whatever it's called--I wanted to do so in order to set permanent aliases.

    For whatever reason, Microsoft has made it an ever increasingly difficult endeavor just to create permanent aliases.

    The problem now is that it won't run the script because it isn't digitally signed.

    I attempted to make a self-signed certificate to sign the blasted thing but I never got anywhere.

    I've looked at a few guides online but they all assume I'm in a server environment or something (which means the steps keep changing or involve unnecessary steps).

    In the end, I wound up with a code-signing cert and the thing is in my current-user cert store.

    I'm trying to get this to work on my Windows 10 Pro desktop but I haven't a clue as to what I'm actually supposed to be doing.

    Is it even possible to get what I'm asking for? *Confused

    P.S. - I have no experience with either Powershell or certificates. The only reason I know what I've mentioned so far is because I spent 2-3 minutes glossing over the help files. My knowledge of PKI has me understanding that you need a private key to sign something, but I can't even get the certificate to validate my own key so it's kind of getting me flustered at this point.
     
    That Random Guy, Jan 15, 2019
    #2
  3. 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:
    Code:
    $mycert = New-SelfSignedCertificate  -Subject "CN=PowerShell signing example" `                -KeyAlgorithm RSA -KeyLength 2048   -Type CodeSigningCert `                  -CertStoreLocation Cert:\LocalMachine\My\ 
    #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:
    Code:
    Move-Item "Cert:\LocalMachine\My\$($mycert.Thumbprint)" Cert:\LocalMachine\Root
    #Finally, with that out of the way, you can sign your script with the following command

    Code:
    Code:
    set-AuthenticodeSignature C:\Path\To\Script\test.ps1 $mycert

    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, Jan 15, 2019
    #3
Thema:

Secure Credentials with Self-Signed Certificates for PowerShell Script

Loading...
  1. Secure Credentials with Self-Signed Certificates for PowerShell Script - Similar Threads - Secure Credentials Self

  2. Problems with Powershell Scripts and Credential Manager VIA Intune

    in Windows 10 Gaming
    Problems with Powershell Scripts and Credential Manager VIA Intune: Hi All,I have been trying to create either a script for entering credentials into Windows Credential Manager via Intune. Credentials are for a mapped drive connection to a non-windows server. Have not been able to make it work yet. I have tried many permutations of scripts,...
  3. Problems with Powershell Scripts and Credential Manager

    in Windows 10 Software and Apps
    Problems with Powershell Scripts and Credential Manager: Hi All,I have been trying to create either a script for entering credentials into Windows Credential Manager via Intune. Credentials are for a mapped drive connection to a non-windows server. Have not been able to make it work yet. I have tried many permutations of scripts,...
  4. 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...
  5. 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...
  6. 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...
  7. 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...
  8. PowerShell script

    in Windows 10 Support
    PowerShell script: The code below tests a series of IPs in a txt file.The result is as follows and is written in a txt file. 19.191.12.161 - online 19.191.12.162 - offline 19.191.12.163 - offline 19.191.12.164 - offline 19.191.12.165 - offline also see the scrennshot Code: $Output= @()$GetIP =...
  9. How to sign Powershell profile w/ self-signed certificate?

    in Windows 10 Support
    How to sign Powershell profile w/ self-signed certificate?: About self-signing drivers: check in with Fernando (Dieter, the owner/operator) at Win-RAID.com. He's been doing that for years because of all the driver mods he posts on his site. Once you load his certificate, you can also load and use any of his drivers. It's a fair amount...
  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...

Users found this page by searching for:

  1. secure credentials with pki certificates for powershell scripts

    ,
  2. new-selfsignedcertificate code signing cert