从 cmd.exe 运行时
powershell .\scripts\scriptname.ps1
Run Code Online (Sandbox Code Playgroud)
其中有一行将纯文本转换为安全字符串
[securestring]$secString = ConvertTo-SecureString $SampleString -AsPlainText -Force
Run Code Online (Sandbox Code Playgroud)
我收到错误:
ConvertTo-SecureString : The 'ConvertTo-SecureString' command was found in the module 'Microsoft.PowerShell.Security', but the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Security'.
Run Code Online (Sandbox Code Playgroud)
但是,如果我直接在 powershell 中打开/运行脚本,它运行正常吗?
如果我尝试手动导入模块,我会得到:
Import-Module : The following error occurred while loading the extended type data file: Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AuditToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AccessToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member …Run Code Online (Sandbox Code Playgroud) powershell ×1