none
SharePoint on premise integration CRM on premise

Ответы

  • Проблему решил, все бонально и просто, скрипт:

    $ key.MachineContext = 1
    $ key.ExportPolicy = 1
    $ Key.Create ()

    $ serverauthoid = new-object -com "X509Enrollment.CObjectId.1"
    $ Serverauthoid.InitializeFromValue ( "1.3.6.1.5.5.7.3.1")
    $ ekuoids = new-object -com "X509Enrollment.CObjectIds.1"
    $ Ekuoids.add ($ serverauthoid)
    $ ekuext = new-object -com "X509Enrollment.CX509ExtensionEnhancedKeyUsage.1"
    $ Ekuext.InitializeEncode ($ ekuoids)

    $ hashAlgorithm = New-Object -ComObject X509Enrollment.CObjectId 
    $ HashAlgorithm.InitializeFromAlgorithmName (1,0,0, "MD5") 

    $ cert = new-object -com "X509Enrollment.CX509CertificateRequestCertificate.1"
    $ cert.InitializeFromPrivateKey (2, $ key, "")
    $ cert.Subject = $ name
    $ cert.Issuer = $ cert.Subject
    $ cert.NotBefore = Get-Date
    $ cert.NotAfter = $ cert.NotBefore.AddYears (10)
    $ Cert.X509Extensions.Add ($ ekuext)
    $ cert.HashAlgorithm = $ hashAlgorithm 
    $ Cert.Encode ()

    $ enrollment = new-object -com "X509Enrollment.CX509Enrollment.1"
    $ Enrollment.InitializeFromRequest ($ CERT)
    $ certdata = $ enrollment.CreateRequest (0)
    $ enrollment.InstallResponse (2, $ certdata, 0, "")

    $ cert = Get-ChildItem cert: \\ localmachine \ my | ? {$ _. Subject -eq "CN = $ hostName"}

    New-Item -Path c: \ certs -ItemType Directory -Force | Из-Null;
    $ cert | Export-PfxCertificate -FilePath "c: \ certs \ $ hostName.pfx" -Password $ pfxPass -Force | Из-Null;
    $ cert | Remove-Item -Force;

    выполняется на ура, если запускать Powershell ISE  от админа))

    • Помечено в качестве ответа Dedman2k3 22 мая 2019 г. 20:08