gpt4 book ai didi

windows - Powershell ConvertTo-SecureString ObjectNotFound

转载 作者:可可西里 更新时间:2023-11-01 10:47:01 25 4
gpt4 key购买 nike

升级到 powershell 3.0 后,现有脚本因错误而停止工作

ConvertTo-SecureString : The term 'ConvertTo-SecureString' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ ConvertTo-SecureString
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (ConvertTo-SecureString:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

我发现 ConvertTo-SecureString 是 supported在 PS 3.0 上。我需要以某种方式包含它吗?

最佳答案

以下不起作用。

C:\contoso>powershell -command {$secured='random text'|ConvertTo-SecureString -AsPlainText -Force;$secured;}

'ConvertTo-SecureString' is not recognized as an internal or external command,
operable program or batch file.

C:\contoso>

以下确实有效。

C:\contoso>copy con: tfile1.ps1
$secured='random text'|ConvertTo-SecureString -AsPlainText -Force;
$secured;
^Z
1 file(s) copied.

C:\contoso>powershell -file tfile1.ps1
System.Security.SecureString

C:\contoso>

这也行。

C:\contoso>powershell "& {$secured='random text'|ConvertTo-SecureString -AsPlainText -Force;$secured}"
System.Security.SecureString

C:\contoso>

我会把为什么它不能作为命令工作给其他人,因为我只是一个 powershell 新手。

S.

关于windows - Powershell ConvertTo-SecureString ObjectNotFound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19957340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com