启动作业连接到 Exchange Online
我需要针对100个邮箱运行并行搜索邮件盒CMDLET,以删除内容,但是它们需要首先符合某些参数,例如启用某些CAS协议和存在的转发地址。我还将其进行了参数化,因此我可以将$ maxjobcount int传递给它,以便跑步者可以指定最大数量的同时运行作业以允许以说明其机器上的资源。
让工作正常,然后到达起始工作组件,这是一个非常简单的功能。
function _StartJob {
param (
$mailAddress
)
Start-Job -Name $mailAddress -Scriptblock {
Get-EXOMailbox $mailAddress -PropertySets Delivery
}
}
这是一个错误,说我需要在使用CMDLET之前运行Connect-ExChangeOnline,这是我在启动工作中学习脚本块实际上是新的powershell.exe进程,所以不要继承模块和会话选项。
有人知道解决这个问题吗?在MFA环境中,这意味着要坐在那里并在几百次中粘贴密码,要么说服变更板和SECOPS部门让我设置具有删除权限的图形应用程序...两者都痛苦地
感谢您的任何建议
I need to run parallel Search-Mailbox cmdlets against 100's mailboxes to delete the content but they need to fit certain parameters first like certain CAS protocols enabled and a forwarding address present. I've also parameterised it so I can pass a $maxJobCount int to it so the runner can specify a maximum number of concurrently running jobs to allow so as to account for resources on their machine.
Got the thing working then got to the start-job component which is a pretty simple function.
function _StartJob {
param (
$mailAddress
)
Start-Job -Name $mailAddress -Scriptblock {
Get-EXOMailbox $mailAddress -PropertySets Delivery
}
}
That's returning an error saying I need to run Connect-ExchangeOnline before using the cmdlets which is where I learned script blocks in Start-Job are actually new PowerShell.exe processes so don't inherit modules and session options.
Does anyone know an easier way around this? In an MFA environment, it either means sitting there and pasting the password in a few hundred times or convincing the Change board and Secops dept to let me setup a graph application with delete rights... both painful
Thanks for any advice
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要根据需要将信用传递到块中。
You just have to pass in the creds into the block however you want.