升级到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我发现在PS3.0上转换到-SecureString是支持。我需要以某种方式把它包括进去吗?
发布于 2013-11-14 07:00:21
Import-Module 'Microsoft.PowerShell.Security'解决这个问题。我不知道为什么这个模块在默认情况下没有加载。
发布于 2019-06-07 04:33:25
以下内容不起作用。
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>我将把为什么它不作为-command工作的原因留给其他人,因为我只是一个powershell新手。
S.
https://stackoverflow.com/questions/19957340
复制相似问题