首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell转换到-SecureString ObjectNotFound

Powershell转换到-SecureString ObjectNotFound
EN

Stack Overflow用户
提问于 2013-11-13 15:13:11
回答 2查看 6.5K关注 0票数 2

升级到powershell 3.0后,现有脚本停止使用错误

代码语言:javascript
复制
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是支持。我需要以某种方式把它包括进去吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-11-14 07:00:21

代码语言:javascript
复制
Import-Module 'Microsoft.PowerShell.Security'

解决这个问题。我不知道为什么这个模块在默认情况下没有加载。

票数 0
EN

Stack Overflow用户

发布于 2019-06-07 04:33:25

以下内容不起作用。

代码语言:javascript
复制
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>

以下是有用的。

代码语言:javascript
复制
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> 

这也很管用。

代码语言:javascript
复制
C:\contoso>powershell "& {$secured='random text'|ConvertTo-SecureString -AsPlainText -Force;$secured}"
System.Security.SecureString

C:\contoso>

我将把为什么它不作为-command工作的原因留给其他人,因为我只是一个powershell新手。

S.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19957340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档