Last active
February 1, 2024 15:24
-
-
Save scusi/9f15ab9ac54c0f515819387a64b788c2 to your computer and use it in GitHub Desktop.
Publishing a Certificate in GAL useing powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://techcommunity.microsoft.com/t5/exchange/upload-s-mime-user-certificate-with-outlook-to-the-gal/m-p/3781147 | |
# | |
# i do not know if this code works, never tried. | |
# i just wanted to keep it, just in case or to try it one day. | |
# Even if it does not work, it might be a good starting point. | |
# ~scusi | |
############################################################################### | |
#Set UserCertificate in EXO | |
############################################################################### | |
Connect-ExchangeOnline | |
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("D:\temp\a.bohren@icewolf.ch_swisssign.cer") | |
$certArray = New-Object System.Collections.ArrayList | |
$certArray.Insert(0,$cert.GetRawCertData()) | |
Set-Mailbox -Identity email address removed for privacy reasons -UserCertificate $certArray | |
$MBX = Get-RemoteMailbox -Identity email address removed for privacy reasons | |
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($mbx.UserCertificate) | |
$Cert | fL | |
############################################################################### | |
#AD | |
############################################################################### | |
$ADUser = Get-ADUser -Identity "a.bohren" -Properties userCertificate | |
$ADUser.userCertificate | |
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($ADUser.userCertificate) | |
$Cert | fL | |
Set-ADUser -Identity "a.bohren" -Clear "userCertificate" | |
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("D:\temp\a.bohren@icewolf.ch_swisssign.cer") | |
Set-ADUser -Identity "a.bohren" -add @{"userCertificate"=$Cert.Rawdata} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment