【发布时间】:2020-07-19 05:29:56
【问题描述】:
现在 AWS Lambda 根据此 blog 支持 PowerShell 核心,是否有人尝试使用 lambda 运行 PowerShell 命令以在混合环境中创建邮箱(在本地和办公室 365 环境中运行 PS cmdlet)?我在网上找不到任何可以做到这一点的东西。大多数 Lambda Powershell 用例似乎都与使用 PowerShell 脚本自动化和管理 AWS 资源有关。 我正在为 REST 服务开发 POC,该服务执行所有邮箱创建操作,并计划使用 API 网关来调用 lambda powershell。
我确实按照 aws documentation 设置了我的环境,并创建了一个执行邮箱操作并创建和部署 lambda 的 PowerShell 脚本。经过测试,我在为 O365 环境创建 PowerShell 会话时遇到以下错误。
脚本 sn-p:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $mycreds -Authentication Basic -AllowRedirection
Write-Host "Created session for PS"
Import-PSSession $Session
Write-Host "Imported Session"
Write-Host "Getting Mailbox"
Get-Mailbox -Identity 'mailbox'
Cloudwatch 日志:
[Error] - This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.
[Information] - Created session for PS
[Error] - Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the command again.
[Information] - Imported Session
[Information] - Getting Mailbox
[Error] - The term 'Get-Mailbox' 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.
想知道是否有人尝试过使用 lambda 调用 Office 365/on-prem 邮箱创建 PS 脚本或指出正确的方向?谢谢
我也想知道,如果使用 AWS lambda powershell core,我是否可以将 winrm 进入另一个 windows 框,以便我可以执行 powershell 邮箱命令?根据 2018 年 10 月的 ans,我们不能,但想知道是否有人知道这方面的最新消息。
【问题讨论】:
标签: amazon-web-services powershell aws-lambda office365 powershell-core