使用以下带有我的用户管理员和角色模拟的命令可以访问我的帐户:
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking -AllowClobber
建立连接后,我可以切换到另一个帐户吗?
我正在尝试创建文件夹和过滤器以使用New-MailboxFolder执行命令,但不能直接从我的帐户中运行。有可能吗?
谢谢
是,您可以更改当前用户。您将创建另一个脚本来以其他用户身份执行您想做的事情。然后在当前脚本中使用:
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Start-Process powershell.exe -Credential $UserCredential -NoNewWindow -ArgumentList "-noexit -command TheNewCreatedScriptFullPath.ps1"