PENDINGscript to delete cert from local machine

Nitin_ted

Nitin_ted

Member
13
0
1
Hi Guys, my company devices auto installed some certificate that cause them to disable wifi and outlook slowness etc.. After i remove certificate manually users device works fine.

Its stored in below location.
Cerlm-->Certificate-localComputer-->Personal-->certificate folder.

I prepared 1 script. Manually its works fine but when i try to package in Ps1 or add in script i got error "Script for Package:RHB000C1, Program: Delete Cert failed with exit code 1"

# Specify the thumbprint of the certificate to delete
$thumbprint = "93e288fafb4cb3153c6e5d380227b16767d47070"

# Get the certificate from the user's certificate store
$cert = Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Thumbprint -eq $thumbprint}

# If the certificate is found, delete it
if ($cert) {
Remove-Item $cert.PSPath
Write-Host "Certificate deleted successfully."
}
else {
Write-Host "Certificate not found."
}
OP
Nitin_ted

Nitin_ted

Member
13
0
1
  • Thread Starter
  • #4
@Garthlocal we not try since users dont have access to powershell. But i try within a IT dept.
@Prajwal Desai- GPO team block users to run powershell. Can this may cause the issue?
Also i run the above script from SCCM but outcome is attached and its wont remove the cert from device.

Attachments

  • issue.JPG
    issue.JPG
    69.7 KB · Views: 1
MJ-Tech

MJ-Tech

Well-Known Member
169
14
18
How did you execute the script manually? i.e., psexec being used? or directly executed the powershell script with administrative privileges?

Try the script with psexec to see whether it works. If it works, it should also work with SCCM.
Garth

Garth

Well-Known Member
Staff member
1,601
133
63
@Garthlocal we not try since users dont have access to powershell. But i try within a IT dept.
If you send a script via ConfigMgr it will run as Local System Account. Therefore if you are having problems with running the script you need to test your script using the local system to see the "Real Error" e.g. maybe the local system account is NOT allowed to run PowerShell scripts...

最新的文章

Forum statistics

Threads
5,424
Messages
21,125
Members
11,598
Latest member
Chodex01