powershell - 将批处理文件变量设置为 Powshell 脚本的输出
问题描述
此 powershell 脚本接受一个参数并返回一个值:
解密密码.ps1
# Decrypts KMS Encrypted password payload by executing the "aws kms decrypt" command
# Arguments: File path containing a password payload as CypherTextBlob
# Returns: Decrypted Password
$file_path=$args[0]
# Remove encryption
$encoded_pass = aws kms decrypt --ciphertext-blob "fileb://$file_path" --query Plaintext --output text --region us-east-1
# Remove base64 encoding from pass
$decrypted = [Text.Encoding]::Utf8.GetString([System.Convert]::FromBase64String($encoded_pass))
return $decrypted
然后在这个批处理文件中,我想为这个脚本的输出设置一个变量。我尝试了以下命令,但它只是将 PASS 的值设置为整个字符串......它不调用该函数
set PASS = powershell.exe -ExecutionPolicy Bypass -Command "C:\installation_files\decrypt_password.ps1 'C:\installation_files\encrypted'"
如何获得decrypt_password.ps1
存储在 PASS 变量中的输出?
解决方案
推荐阅读
- python - 在另一个文件中注释 Flask-Resource
- spring - 使用嵌入式 tomcat 未在 Spring Boot 中映射请求
- php - 奏鸣曲碳库中的当年使用方法
- java - 如何在不创建 File 对象的情况下将 BufferedImage 附加到 MimeBodyPart
- python - 将变量与正则表达式变量进行比较
- python - 为什么 Urlopen 在某些网站上运行缓慢
- excel - 水平数据上 MATCH 函数的替代方法
- ios - 当我运行 appium 代码时,出现类似“处理命令时发生未知服务器端错误”的错误
- vue.js - Vue.draggable:为什么不能将子项拖到另一个项上?
- sql - oracle sql中特定条件下的用户输入