SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ToRemove = Get-ChildItem -Path Cert:LocalMachineMy | ? {($_.Subject -match [System.Net.Dns]::GetHostByName($env:COMPUTERNAME).HostName) -and ($_.EnhancedKeyUsageList -match "Client Authentication") -and ($_.EnhancedKeyUsageList -match "Server Authentication")}
  2. $CertsInStore = Get-ChildItem -Path Cert:LocalMachineMy
  3. $Store = Get-Item -Path Cert:LocalMachineMy
  4. foreach ($ToRemove in $CertsInStore)
  5. {
  6.     $Store.Open("ReadWrite")
  7.     $Store.Remove($ToRemove)
  8.     $Store.Close()
  9. }
  10. $Certificates = Get-ChildItem -Path Cert:LocalMachineMy | ? {$_.Subject -match [System.Net.Dns]::GetHostByName($env:COMPUTERNAME).HostName}
  11. if (-not [string]::IsNullOrEmpty($Certificates))
  12. {
  13.     $Result = "Multiple certificates present" | Out-File "C:SCOMcertimport-result.txt"
  14.     exit
  15. } else {
  16.     Import-Certificate -FilePath "C:SCOMcertcert_XF-S-RDSAP01P.xe.abb.com.crt" -CertStoreLocation Cert:LocalMachineMy
  17. }
  18. $Certificates = Get-ChildItem -Path Cert:LocalMachineMy | ? {$_.Subject -match [System.Net.Dns]::GetHostByName($env:COMPUTERNAME).HostName}
  19. if ([string]::IsNullOrEmpty($Certificates))
  20. {
  21.     $Result = "New certificate failed to import." | Out-File "C:SCOMcertimport-result.txt"
  22. } else {
  23.     $Result = "New certificate imported in system store." | Out-File "C:SCOMcertimport-result.txt"
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top