Oh, sorry. Thanks.
This is the script (ExportCert.ps1):
Get-ChildItem -Path 'Cert:\LocalMachine\WebHosting' | Where-Object { $_.hasPrivateKey } | Where-Object {$_.Subject -like "*mail.domain.com*"} | Foreach-Object {&certutil.exe @('-exportpfx', '-f', '-p', '45****************gew',$_.Thumbprint, "C:\Smartermail\Certificates\mail.domain.com.pfx")}
Bat file and error:
C:\SmarterMail\Scripts>ExportCert.bat
Powershell.exe -executionpolicy remotesigned -File c:\SmarterMail\Scripts\ExportCert.ps1
MY "Personal"
CertUtil: -exportPFX command FAILED: 0x80090011 (-2146893807 NTE_NOT_FOUND)
CertUtil: Object was not found.