Generate-EDZCertificate: verschil tussen versies

Uit Brakwiki
Ga naar: navigatie, zoeken
 
Regel 1: Regel 1:
<syntaxhighlight lang="PowerShell">
+
<syntaxhighlight lang="PowerShell" class="nowrap">
 
param ([parameter(mandatory=$true)]$MachineFQDN)
 
param ([parameter(mandatory=$true)]$MachineFQDN)
  

Huidige versie van 3 okt 2017 om 15:20

param ([parameter(mandatory=$true)]$MachineFQDN)

$mypwd = ConvertTo-SecureString -String "Password" -Force AsPlainText

#Get-Certificate -Template ConfigMgrClientCertificateforEDZ -Url ldap:///CN=NET-CA01 -dnsName $MachineFQDN -CertStoreLocation Cert:\LocalMachine\My -SubjectName "CN=$MachineFQDN"
Set-Location cert:
cd \LocalMachine\My
#$cert = GCI (Get-ChildItem | where {($_.Subject -eq "CN=$MachineFQDN") -and ($_.FriendlyName -eq "")} | Select Thumbprint).thumbprint
#$cert.Friendlyname = "ConfigMgr Client Certificate"


Get-Certificate -Template SCOMCertificateAPX -Url ldap:///CN=NET-CA01 -dnsName $MachineFQDN -CertStoreLocation Cert:\LocalMachine\My -SubjectName "CN=$MachineFQDN"
$cert2 = GCI (Get-ChildItem | where {($_.Subject -eq "CN=$MachineFQDN") -and ($_.FriendlyName -eq "")} | Select Thumbprint).thumbprint
$cert2.Friendlyname = "SCOM and SCCM Certificate"




$certs = GCI (Get-ChildItem | where {$_.Subject -eq "CN=$MachineFQDN"} | Select Thumbprint).thumbprint
foreach ($certificate in $certs) {
  $temp = $certificate.FriendlyName
  $certificate | Export-PfxCertificate -FilePath "E:\Scripts\Beheertaken\Certificates\$temp-$MachineFQDN.pfx" -Password $mypwd
  $certificate | Export-Certificate -FilePath "E:\Scripts\Beheertaken\Certificates\$temp-$MachineFQDN.cer" -Type CERT
}
Set-Location e: