import ssl cert on windows - password errors

I am trying to import a certificate using both

  1. win_certificate_store
  • name: Import certificate be used by IIS
    win_certificate_store:
    path: c:\temp\SDCW.abc.com.pfx
    password: test01
    state: present
    file_type: pkcs12
    store_location: LocalMachine
    store_name: My
    key_storage: machine
    key_exportable: yes
    become: yes
    become_method: runas
    become_user: SYSTEM
  1. win_shell + Import-PfxCertificate
  • name: Import certificate to be used by IIS, using win_shell (powershell)
    win_shell: |
    $securePassword = “test01”
    $mypwd = ConvertTo-SecureString -String $securePassword -Force -AsPlainText
    $certFilePath = “c:\temp\SDCW.abc.com.pfx”
    Import-PfxCertificate -FilePath $certFilePath -CertStoreLocation cert:\LocalMachine\My -Exportable -Password $mypwd

Both ways always give me errors relating to password

The specified network password is not correct

I am able to run the above PS script locally on my local computer and import the cert successfully, so I know the password is correct.

If anyone has any ideas, it would be appreciated.

Thanks