Powershell Office 365 日历权限



我正在构建一个脚本来为特定人员分配日历权限。我经常这样做,以至于想要一个脚本。 这就是我到目前为止所拥有的。

#authenticate into the office 365 account    
$LiveCred = Get-Credential
#Create new session    
$Session = New-PSSession -ConfigurationName Microsoft.Exchange `
                         -ConnectionUri https://ps.outlook.com/powershell/ `
                         -Credential $LiveCred `
                         -Authentication Basic `
                         -AllowRedirection
#Import Session    
Import-PSSession $Session
#Ask for user information    
$UserCal = Read-Host -Prompt "Who's calandar are we sharing?"
$HostCal = Read-Host -Prompt "Who's needs access?"
$AccessCal = Read-Host -Prompt "What kind of access?"
#Set access for user
Add-MailboxFolderPermission -Identity ${$UserCal}:calendar `
                            -User $HostCal `
                            -AccessRights $AccessCal

我相信问题出在${$UserCal}:calendar如何以这种方式使用变量?

仅供参考,我对Powershell和脚本很陌生。感谢您的任何帮助!

在做了更多的研究后找到了我问题的答案!

${$UserCal}:calendar

应该是

$UserCal`:calendar

全部固定,工作完美!

最新更新