Write a Powershell script that checks for a remote computer's certificate that is close…
- User
Write a Powershell script that checks for a remote computer's certificate that is close to expiration and manually re-enroll that certificate
Assistant
# Import the required modules. import-module ActiveDirectory import-module CertificateServicesClient # Get the computer name from the command line arguments. if ($args.length -eq 0) { write-error "You must specify a computer name." exit } $computerName = $args[0] # Get the computer's certificate. $computerCertificate = get-adcomputer $computerName | get-certificate -thumbprint # Check if the certificate is close to expiration. $expirationDate = $computerCertificate.notafter if ($expirationDate -lt (get-date).adddays(30)) { # Manually re-enroll the certificate. $computerCertificate | renew-certificate write-host "The certificate for $computerName has been re-enrolled." } else { write-host "The certificate for $computerName is not close to expiration." }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.