Forum Discussion
sassmath
Sep 27, 2023Copper Contributor
PowerShell code does not work
PS C:\Foo> $PasswordHT = @{
>> String = 'Pa$$w0rd'
>> AsPlainText = $true
>> Force = $true
>> }
PS C:\Foo> $SecurePW = ConvertTo-SecureString @$PasswordHT
ConvertTo-SecureString : La valeur de paramètre « @System.Collections.Hashtable » n’est pas une chaîne chiffrée valide.
Au caractère Ligne:1 : 13
+ $SecurePW = ConvertTo-SecureString @$PasswordHT
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument : (:) [ConvertTo-SecureString], PSArgumentException
+ FullyQualifiedErrorId : ImportSecureString_InvalidArgument,Microsoft.PowerShell.Commands.ConvertToSecureStringComma
nd
""""Why my code does not work, I tried to improve but I still have an error that returned to me.""""""
Your code has one small syntax error.
In your final line, it should be "@PasswordHT" rather than "@$PasswordHT".
Cheers,
Lain
- LainRobertsonSilver Contributor
Your code has one small syntax error.
In your final line, it should be "@PasswordHT" rather than "@$PasswordHT".
Cheers,
Lain
- sassmathCopper ContributorThank you so much for solving my problem.
- Andres-BohrenSteel ContributorHi sassmath,
Use this Code:
$SecureString = ConvertTo-SecureString "Pass@word1" -AsPlainText -Force
Regards
Andres- sassmathCopper Contributor
Andres-Bohren Thank you very much for the answer I already tried