New-SelfSignedCertificate to create certificate gives Access Denied
As mentioned in the comments, although PowerShell.exe is run under a user account with "Administrative Rights". The process cannot use those rights unless it is elevated.
PowerShell windows will add "Administrator:" in the title bar by default. Otherwise you can check if you an administrator by running this command:
([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
When you launch PowerShell if done by GUI, you can Right-Click -> Run as Administrator.
Otherwise you can spawn a new process that is elevated by running Start-Process powershell.exe -Verb Runas
Create a certificate for your local user account by specifying a different certificate location:
New-SelfSignedCertificate -CertStoreLocation "Cert:\CurrentUser\My" [...]