locked
PowerShell to add a Certificate to "Trusted Root Certification Authorities" from https RRS feed

  • Question

  • Hey all,

    I have a self signed cert on IIS and I need to deploy it to multiple workstations. I was wondering if there is a way for me to add it to my PS Script so I can get it to install it directly from the server.

    Right now I need to visit the web services from the below using IE and install it once it gives me a certificate error and then I can move ahead. I need to install it to the Root Authority

    https://servername:443/example/example.asmx

    I have tried the below which my colleague told me to try. I am totally new to scripting and PS. 

    ## Set up variables and objects
    $url = 'https://servername:443/example/example.asmx'
    $filename = [System.IO.Path]::GetTempFileName()
    $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
    $store = new-object System.Security.Cryptography.X509Certificates.X509Store(“Root”,”LocalMachine”)

    ## Download the cert file
    Invoke-WebRequest -Uri $url -OutFile $filename
    $pfx.Import($filename)
    $store.Open(“MaxAllowed”)
    $store.Add($pfx)
    $store.Close()

    ## clean up
    Remove-Item $filename

    PLEASE HELP!! :)


    Tuesday, April 9, 2019 3:14 AM

All replies