how to manage my office 365 remotely

This topic contains 1 reply, has 2 voices, and was last updated by  Rick 1 week, 3 days ago.

  • Author
    Posts
  • #79841

    situscript
    Participant

    hello All,

    i am having a problem in connecting my local office 365 and manage things remotely.
    the below scrip works fine when i am trying to connect to my office 365 from my laptop but how do i do if i want to execute the a script 3 times a day when my laptop is off as well.

    so i have to got a management server where i can run my script and here is the problem arises.
    anybody is having any solution here.. i know that i must be missing a very small point here.

    $filepath = "C:\Temp"

    #set outlook to open
    $o = New-Object -comobject outlook.application
    $n = $o.GetNamespace(“MAPI”)

    #you'll get a popup in outlook at this point where you pick the folder you want to scan
    $Account = $n.Folders | ? { $_.Name -eq 'username@domain.com' };
    $Inbox = $Account.Folders | ? { $_.Name -match 'Inbox' };
    $f = $Inbox.Folders | ? { $_.Name -match 'SHO' };

    #date string to search for in attachment name
    $email = $f.items.getlast()
    $email.Attachments | %{$_.saveasfile((join-path $filepath $_.filename))}

  • #79885

    Rick
    Participant

    Because your code uses outlook automation you need to install outlook on the management server as well as having your email profile configured. You might want to try something like this using exchange cmdlets.

    https://4sysops.com/archives/auto-archive-attachments-from-an-exchange-mailbox-with-powershell/

You must be logged in to reply to this topic.