Generate-EDZCertificate

Uit Brakwiki
Versie door Ben (Overleg | bijdragen) op 3 okt 2017 om 15:05
Ga naar: navigatie, zoeken
 1 param ([parameter(mandatory=$true)]$MachineFQDN)
 2 
 3 $mypwd = ConvertTo-SecureString -String "Password" -Force AsPlainText
 4 
 5 #Get-Certificate -Template ConfigMgrClientCertificateforEDZ -Url ldap:///CN=NET-CA01 -dnsName $MachineFQDN -CertStoreLocation Cert:\LocalMachine\My -SubjectName "CN=$MachineFQDN"
 6 Set-Location cert:
 7 cd \LocalMachine\My
 8 #$cert = GCI (Get-ChildItem | where {($_.Subject -eq "CN=$MachineFQDN") -and ($_.FriendlyName -eq "")} | Select Thumbprint).thumbprint
 9 #$cert.Friendlyname = "ConfigMgr Client Certificate"
10 
11 
12 Get-Certificate -Template SCOMCertificateAPX -Url ldap:///CN=NET-CA01 -dnsName $MachineFQDN -CertStoreLocation Cert:\LocalMachine\My -SubjectName "CN=$MachineFQDN"
13 $cert2 = GCI (Get-ChildItem | where {($_.Subject -eq "CN=$MachineFQDN") -and ($_.FriendlyName -eq "")} | Select Thumbprint).thumbprint
14 $cert2.Friendlyname = "SCOM and SCCM Certificate"
15 
16 
17 
18 
19 $certs = GCI (Get-ChildItem | where {$_.Subject -eq "CN=$MachineFQDN"} | Select Thumbprint).thumbprint
20 foreach ($certificate in $certs) {
21   $temp = $certificate.FriendlyName
22   $certificate | Export-PfxCertificate -FilePath "E:\Scripts\Beheertaken\Certificates\$temp-$MachineFQDN.pfx" -Password $mypwd
23   $certificate | Export-Certificate -FilePath "E:\Scripts\Beheertaken\Certificates\$temp-$MachineFQDN.cer" -Type CERT
24 }
25 Set-Location e: