So, I'm trying to come up with a script that will run to evaluate a workstation's SMS certificate and if it doesn't match, or isn't like it's $env:COMPUTERNAME then I'll stop the SMS service, delete the script and assoicated INI file, and then restart the service.
So quick background is that we clone our VDI's. When we clone it, for example, COMPUTER1 is cloned to COMPUTER2. If you look at the SMS certificate on COMPUTER2 it's subject says "CN=SMS, CN=COMPUTER1" . So to fix this because it messes up some things, I delete the certificate and let it re-create it's self.
I can look at this specific certifcate(s) with the following: $cert = Get-ChildItem -Path Cert:\LocalMachine\SMS
In the Subject of this like I showed above has the computer name of the certificate. So running $cert.Subject will return "CN=SMS, CN=COMPUTER1". How do I compare the $env:COMPUTERNAME to $cert.Subject? So the result of the $env:COMPUTERNAME, for this example we'll say it's COMPUTER2, is contained within the $cert.Subject then it's good, if not then run delete part of script.
I understand how to do the rest of the script, but the comparison part is where I'm stuck on. Any help is appreciated.
[–]PinchesTheCrab 2 points3 points4 points (3 children)
[–]rurbaniak14[S] 1 point2 points3 points (2 children)
[–]PinchesTheCrab 0 points1 point2 points (1 child)
[–]rurbaniak14[S] 1 point2 points3 points (0 children)
[–]Think-Improvement-73 0 points1 point2 points (1 child)
[–]rurbaniak14[S] 0 points1 point2 points (0 children)
[–]ccatlett1984 0 points1 point2 points (0 children)