Import-Clixml : Key not valid for use in specified state.


When you export credentials using the following command:

$Credential = Get-Credential

$Credential | Export-CliXml -Path “C:\Credentials.Cred”

Then, you want to use these credentials that have been exported previously, in a script for example.

Bug

You may get the following error message:

Import-Clixml : Key not valid for use in specified state.

Fix

You cannot use these credentials because items encrypted with one account cannot be decrypted using another account.

So, you must “runas” the script with the account you created the credentials file.

About Nicolas 282 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.