次のスクリプトを使用して、Outlook に新しい配布リストを作成するだけです。
$outlook = new-object -com Outlook.Application
$contacts = $outlook.Session.GetDefaultFolder(10)
$dl = $contacts.Items.Add("IPM.DistLIst")
$dl.DLName = "Group A"
$dl.Save()
そして私は「manager」という名前の電子メールアドレス「manager@abc.com」を持っています
これを新しく作成した配布リストに追加するには、powershell を使用する方法を教えてください。
何らかの理由でpowershellを使用する必要があり、これを試しました:
Add-DistributionGroupMember -Idneity "Group A" -Member "manager@abc.com"
しかし、このエラーが発生します:
The term 'Add-DistributionGroupMember' is not recognized as the name of a cmdlet, function,
script file, or operable program.
助けてください
[更新]今、私は動作するスクリプトを持っています:
$outlook = new-object -com Outlook.Application
$contacts = $outlook.Session.GetDefaultFolder(10)
$session = $outlook.Session
$session.Logon("Outlook")
$namespace = $outlook.GetNamespace("MAPI")
$recipient = $namespace.CreateRecipient("John Smith@abc.com") # this has to be an exsiting contact
$recipient.Resolve() # check if this returns true
$DL = $contacts.Items.Add("IPM.DistList")
$DL.DLName = "test dl"
$DL.AddMember($recipient)
$DL.Save()