Powershell脚本在Outlook中创建会议

时间:2019-06-13 13:10:39

标签: powershell outlook

我正在尝试创建一个PowerShell脚本来在Outlook中创建会议。我陷入了设置会议时区的代码中。我要查找的时区是CSTPSTESTAEST

$Outlook = New-Object -ComObject Outlook.Application
$OutlookFolders = $Outlook.Session.Folders.Item(1).Folders
$tzs = $Outlook.TimeZones
$NewEvent = $Outlook.CreateItem(1)
$NewEvent.Subject = "Meeting";
$NewEvent.Start = [datetime]”6/13/2019 19:00"
$NewEvent.End = [datetime]"6/13/2019 20:00"
$NewEvent.StartTimeZone =$tzs.CurrentTimeZone.Name("Central Standard 
Time")
$NewEvent.EndTimeZone = $tzs.CurrentTimeZone.Name("Central Standard 
Time")
$NewEvent.SendUsingAccount = 'name@abc.com'
$NewEvent.Recipients('name@abc.com')
$NewEvent.save()

我在上面的代码中遇到的错误列在下面

  

找不到“ ID”和参数计数的重载:“ 1”   C:\ Powershell \ outlook-base.ps1:12 char:5 + $ NewEvent.StartTimeZone =   $ Outlook.TimeZones.CurrentTimeZone.ID(“ ... + CategoryInfo:   未指定:(:) [],GetValueInvocationException +   FullyQualifiedErrorId:RuntimeException找不到其重载   “ ID”和参数计数:“ 1”在C:\ Powershell \ outlook-base.ps1:13   char:5 + $ NewEvent.EndTimeZone =   $ Outlook.TimeZones.CurrentTimeZone.ID(“ Ce ... + CategoryInfo:   未指定:(:) [],GetValueInvocationException +   FullyQualifiedErrorId:RuntimeException

1 个答案:

答案 0 :(得分:1)

以此更新第8行和第9行:

$NewEvent.StartTimeZone =$tzs["Central Standard Time"]
$NewEvent.EndTimeZone = $tzs["Central Standard Time"]