받은 편지함을 길들이기 위해 어떤 Powershell 모듈을 사용할 수 있나요?

받은 편지함을 길들이기 위해 어떤 Powershell 모듈을 사용할 수 있나요?

받은 편지함 규칙을 생성/제거/관리하기 위해 Outlook의 GUI를 사용하는 데 지쳤습니다. 영원히 걸리고 짜증납니다.

Powershell에는 클라이언트 측뿐만 아니라 서버 측에서도 이 작업을 수행할 수 있는 cmdlet이 있다는 것을 알고 있습니다.

저는 서버측에 접근할 수 없으며 이러한 규칙을 사용하여 내 받은편지함을 관리하는 데에만 관심이 있습니다.

다음 문서에서는 이 작업에 유용한 몇 가지 cmdlet을 언급하는 것 같지만 라이브러리를 어디서 가져올지 모르기 때문에 사용할 수 없습니다.

https://www.codetwo.com/admins-blog/managing-outlook-rules-powershell/

cmdlet을 먼저 설치하려면 어떻게 해야 하나요? 어디서 구할 수 있으며, 스크립트로 가져오려면 무엇이 필요합니까?

답변1

해당 댓글 섹션에 비해 너무 길기 때문에 여기에 배치합니다.

사서함을 길들이는 것은 독립 실행형 클라이언트(Fat, 클라우드 또는 둘 다 - Outlook Fat 클라이언트에 Outlook.com 계정을 직접 추가할 수 있다는 점을 기억하십시오.) 또는 기업의 사용자에 대해서만 이야기하고 있는지 묻는 질문입니다. .

로컬 Outlook을 제어하기 위해 Exchange cmdlet을 사용하지 않습니다. Exchange cmdlet을 사용하려면 컴퓨터에 Exchange 관리 셸을 설치해야 합니다.

Exchange 관리 도구 설치

...또는 PowerShell 암시적 원격 기능을 사용하여 해당 cmdlet을 호스트에 프록시합니다. 암시적 원격은 O365용 Exchange cmdlet을 사용하는 방법이기도 합니다.이는 Microsoft와 웹 전체 및 Youtube 비디오의 많은 블로그에서 잘 문서화되어 있고 세부 정보가 있습니다.

Office 365 PowerShell에 연결

단일 Windows PowerShell 창에서 모든 Office 365 서비스에 연결

모든 Office 365 서비스 PowerShell에 연결(MFA도 지원)

이러한 노력을 위해 사전 구축된 모듈도 있습니다.

커넥트-O365 1.7.9

PowerShell을 사용하여 Office 365 서비스에 연결

Office 365 또는 Exchange 온프레미스에 연결하기 위한 도우미 기능이 포함된 PowerShell 스크립트입니다. 동일한 자격 증명(MFA 아님)을 사용하여 다양한 Office 365 서비스에 쉽게 연결할 수 있습니다. 더 이상 각 워크로드에 연결하는 다양한 방법을 기억할 필요가 없습니다.

Exchange 관리 셸(PowerShell 사용)에서 사용자의 Outlook 규칙 관리

유튜브 - Powershell O365

Outlook Online에는 Exchange, EWS와 마찬가지로 작업할 수 있는 Rest API가 있습니다.

Office 365 관리 API 개요

아웃룩 클라이언트

유튜브-

Outlook REST API는 모든 Office 365 또는 outlook.com 사용자가 메일, 일정 및 연락처 데이터에 쉽게 액세스할 수 있는 방법을 제공합니다. 이 비디오에서는 API V2.0에 도입된 몇 가지 주요 기능인 웹후크, 사진, 미리 알림 및 시간대를 살펴보겠습니다.

PowerShell을 사용하여 Outlook 받은 편지함 데이터 마이닝

# Get-OutlookInBox function
Function Get-OutlookInBox
{
  <#

   .Synopsis
    This function returns InBox items from default Outlook profile

   .Description
    This function returns InBox items from default Outlook profile. It
    uses the Outlook interop assembly to use the olFolderInBox enumeration.

    It creates a custom object consisting of Subject, ReceivedTime, Importance,
    SenderName for each InBox item.

    *** Important *** depending on the size of your InBox items this function
    may take several minutes to gather your InBox items. If you anticipate
    doing multiple analysis of the data, you should consider storing the
    results into a variable, and using that.

   .Example
    Get-OutlookInbox |
    where { $_.ReceivedTime -gt [datetime]”5/5/11″ -AND $_.ReceivedTime -lt `

    [datetime]”5/10/11″ } | sort importance

    Displays Subject, ReceivedTime, Importance, SenderName for all InBox items that
    are in InBox between 5/5/11 and 5/10/11 and sorts by importance of the email.

   .Example
    Get-OutlookInbox | Group-Object -Property SenderName | sort-Object Count

    Displays Count, SenderName and grouping information for all InBox items. The most
    frequently used contacts appear at bottom of list.

   .Example
    $InBox = Get-OutlookInbox

    Stores Outlook InBox items into the $InBox variable for further
    “offline” processing.

   .Example
    ($InBox | Measure-Object).count

    Displays the number of messages in InBox Items

   .Example
    $InBox | where { $_.subject -match ‘2011 Scripting Games’ } |
    sort ReceivedTime -Descending | select subject, ReceivedTime -last 5
    Uses $InBox variable (previously created) and searches subject field
    for the string ‘2011 Scripting Games’ it then sorts by the date InBox.
    This sort is descending which puts the oldest messages at bottom of list.
    The Select-Object cmdlet is then used to choose only the subject and ReceivedTime
    properties and then only the last five messages are displayed. These last
    five messages are the five oldest messages that meet the string.

   .Notes
    NAME:  Get-OutlookInbox
    AUTHOR: ed wilson, msft
    LASTEDIT: 05/13/2011 08:36:42
    KEYWORDS: Microsoft Outlook, Office
    HSG: HSG-05-26-2011

   .Link
     Http://www.ScriptingGuys.com/blog

 #Requires -Version 2.0

 #>

 Add-type -assembly “Microsoft.Office.Interop.Outlook” | out-null

 $olFolders = “Microsoft.Office.Interop.Outlook.olDefaultFolders” -as [type]

 $outlook = new-object -comobject outlook.application

 $namespace = $outlook.GetNameSpace(“MAPI”)

 $folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
 $folder.items |

 Select-Object -Property Subject, ReceivedTime, Importance, SenderName

} #end function Get-OutlookInbox

이 작업을 수행하려면 O365의 관리자여야 합니다. 데스크톱의 Outlook이 Exchange가 아닌 것처럼 O365의 Outlook은 Exchange가 아닙니다. Outlook 클라이언트에서 작업하려면 위에서 언급한 대로 Outlook COM을 사용해야 합니다. 이는 온라인에서는 해당되지 않습니다.

PowerShell은 Outlook 주소를 검색합니다.

방법: Outlook을 사용하여 Powershell에서 메일 보내기

Powershell을 사용하여 Outlook 개체 조작

답변2

내가 아는 한, Outlook에 사용할 수 있는 표준 Powershell 모듈은 없지만 Microsoft.Office.Interop.Outlook네임스페이스에 대한 액세스를 제공하는 Outlook API를 사용할 수 있습니다. 새 규칙을 생성하는 간단한 예는 다음과 같습니다.

먼저 네임스페이스를 얻습니다.

Add-Type -assembly "Microsoft.Office.Interop.Outlook"
$Outlook = New-Object -comobject Outlook.Application
$namespace = $Outlook.GetNameSpace("MAPI")

이제 원본 폴더(받은 편지함)를 지정하고 새 규칙을 생성한 다음 복사할 폴더(알림)를 지정합니다.

$inbox = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$MyFolder1 =
  $namespace.Folders.Item('[email protected]').Folders.Item('NOTIFICATIONS')
$rules = $namespace.DefaultStore.GetRules()
$rule = $rules.create("My rule1: Receiving Notification",
  [Microsoft.Office.Interop.Outlook.OlRuleType]::olRuleReceive)

$rule_body = $rule.Conditions.Subject
$rule_body.Enabled = $true
$rule_body.Text = @('Completed Notification')
$action = $rule.Actions.CopyToFolder
$action.enabled = $true
  [Microsoft.Office.Interop.Outlook._MoveOrCopyRuleAction].InvokeMember(
    "Folder",
    [System.Reflection.BindingFlags]::SetProperty,
    $null,
    $action,
    $MyFolder1)
$rules.Save()

Powershell에서 Outlook 네임스페이스를 사용하는 방법에 대한 추가 예제와 정보는 여기에서 찾을 수 있습니다. https://docs.microsoft.com/en-us/archive/msdn-magazine/2013/march/powershell-managing-an-outlook-mailbox-with-powershell

또한 여기에서 Outlook 개체 모델에 대한 모든 정보를 찾을 수 있습니다. https://docs.microsoft.com/nl-nl/office/vba/api/overview/Outlook/object-model

관련 정보