使用PowerShell创建文件夹和过滤器

问题描述 投票:1回答:1

使用以下带有我的用户管理员和角色模拟的命令可以访问我的帐户:

$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执行命令,但不能直接从我的帐户中运行。有可能吗?

谢谢

powershell exchangewebservices
1个回答
1
投票

是,您可以更改当前用户。您将创建另一个脚本来以其他用户身份执行您想做的事情。然后在当前脚本中使用:

$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"
© www.soinside.com 2019 - 2024. All rights reserved.