$cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=ProxmoxVMGUI" -CertStoreLocation Cert:\CurrentUser\My Write-Host "Certificate Thumbprint: $($cert.Thumbprint)" $pfxPath = "D:\selftools\proxmox-task\code_signing.pfx" $securePassword = New-Object -TypeName System.Security.SecureString $ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword) $plainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($ptr) [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr) $pwd = ConvertTo-SecureString -String $plainPassword -AsPlainText -Force Export-PfxCertificate -Cert $cert -FilePath $pfxPath -Password $pwd Write-Host "Certificate exported to $pfxPath"