Powershell Office 365日历权限

时间:2017-01-18 20:02:06

标签: powershell office365

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

#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和脚本的新手。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

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

"Normal Birth Weight"

应该是

${$UserCal}:\calendar

所有固定和完美的工作!