@EIGhaliBenchekroun-6065, Thank you for reaching out. Are you following the exact code for PowerShell present in that article?
As that script helps in creating a self signed certificate first and then it exports the private key (as .pfx file) and public key (as .cer file). For the test purpose, you can also export the private key manually and then check if the export works or not.
If that fails, will have to dig deeper to understand why the cert creation is failing. But ideally I have personally followed that script and it works for me.