How to check if Outlook can connect to Exchange from a script? Unicorn Meta Zoo #1: Why...

How to avoid introduction cliches

Prove the alternating sum of a decreasing sequence converging to 0 is Cauchy.

My admission is revoked after accepting the admission offer

Can you stand up from being prone using Skirmisher outside of your turn?

What was Apollo 13's "Little Jolt" after MECO?

What’s with the clanks in Endgame?

What is a 'Key' in computer science?

Reattaching fallen shelf to wall?

"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"

Is it acceptable to use working hours to read general interest books?

I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?

What is the term for a person whose job is to place products on shelves in stores?

Is Electric Central Heating worth it if using Solar Panels?

Passing args from the bash script to the function in the script

PIC mathematical operations weird problem

Why did Israel vote against lifting the American embargo on Cuba?

Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?

Could moose/elk survive in the Amazon forest?

Are all CP/M-80 implementations binary compatible?

Do I need to protect SFP ports and optics from dust/contaminants? If so, how?

How would I use different systems of magic when they are capable of the same effects?

Is Bran literally the world's memory?

Has a Nobel Peace laureate ever been accused of war crimes?

Putting Ant-Man on house arrest



How to check if Outlook can connect to Exchange from a script?



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Come Celebrate our 10 Year Anniversary!Troubleshooting Outlook 2010 Exchange SetupScript to export Outlook rulesMessages showing distinguished name Exchange/Outlook 2010Deleting Outlook 2010/2013 “Suggested Contacts” from a particular mail domain with a scriptScript to remove Exchange 2010 AutoMapping for all mailboxesIf using outlook to connect to exchange, how to recover contact groups?Exchange 2013 Outlook “Send to cache”How do I find the mailbox name for an exchange 2010 account so I can connect using mapiHow can I recreate the default mail profile for an exchange outlook account without removing the old one?Exchange Server replaced but Outlook still trying to connect to old Exchange Server installation





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















Is there any way to check if Outlook can successfully connect to Exchange from Powershell? I would like to schedule that script for logging purposes.



After some research, I managed to cook up the following:



$outlook = New-Object -ComObject Outlook.Application
Start-Sleep -s 5

$session = $outlook.session
$inbox = $session.GetDefaultFolder([Microsoft.Office.Interop.Outlook.olDefaultFolders]::olFolderInbox)

$date = Get-Date
If ($session.Offline) {
$output = "Fail, mode $($session.ExchangeConnectionMode.ToString())"
} Else {
$output = "Success"
}
"[$date] $output `n" | Out-File -Append "$HOMEol_log.txt" -Encoding "UTF8"
$outlook.Quit()


This writes "Success" even if I pull the cable. A different way to check I found is



$validStates = "olCachedConnectedDrizzle", "olCachedConnectedDrizzle", "olCachedConnectedHeaders", "olOnline"
if ($validStates -contains $session.ExchangeConnectionMode.ToString()) {...}


...which always fails, since connection mode here is olCachedDisconnected for some reason. If I manually open Outlook, I can see the connection is OK. All of this is happening in an internal network, so no O365 and such.



PS: Please tell me if the question is more appropriate for superuser.com, I'll move it there if need be.









share







New contributor




Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    Is there any way to check if Outlook can successfully connect to Exchange from Powershell? I would like to schedule that script for logging purposes.



    After some research, I managed to cook up the following:



    $outlook = New-Object -ComObject Outlook.Application
    Start-Sleep -s 5

    $session = $outlook.session
    $inbox = $session.GetDefaultFolder([Microsoft.Office.Interop.Outlook.olDefaultFolders]::olFolderInbox)

    $date = Get-Date
    If ($session.Offline) {
    $output = "Fail, mode $($session.ExchangeConnectionMode.ToString())"
    } Else {
    $output = "Success"
    }
    "[$date] $output `n" | Out-File -Append "$HOMEol_log.txt" -Encoding "UTF8"
    $outlook.Quit()


    This writes "Success" even if I pull the cable. A different way to check I found is



    $validStates = "olCachedConnectedDrizzle", "olCachedConnectedDrizzle", "olCachedConnectedHeaders", "olOnline"
    if ($validStates -contains $session.ExchangeConnectionMode.ToString()) {...}


    ...which always fails, since connection mode here is olCachedDisconnected for some reason. If I manually open Outlook, I can see the connection is OK. All of this is happening in an internal network, so no O365 and such.



    PS: Please tell me if the question is more appropriate for superuser.com, I'll move it there if need be.









    share







    New contributor




    Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      Is there any way to check if Outlook can successfully connect to Exchange from Powershell? I would like to schedule that script for logging purposes.



      After some research, I managed to cook up the following:



      $outlook = New-Object -ComObject Outlook.Application
      Start-Sleep -s 5

      $session = $outlook.session
      $inbox = $session.GetDefaultFolder([Microsoft.Office.Interop.Outlook.olDefaultFolders]::olFolderInbox)

      $date = Get-Date
      If ($session.Offline) {
      $output = "Fail, mode $($session.ExchangeConnectionMode.ToString())"
      } Else {
      $output = "Success"
      }
      "[$date] $output `n" | Out-File -Append "$HOMEol_log.txt" -Encoding "UTF8"
      $outlook.Quit()


      This writes "Success" even if I pull the cable. A different way to check I found is



      $validStates = "olCachedConnectedDrizzle", "olCachedConnectedDrizzle", "olCachedConnectedHeaders", "olOnline"
      if ($validStates -contains $session.ExchangeConnectionMode.ToString()) {...}


      ...which always fails, since connection mode here is olCachedDisconnected for some reason. If I manually open Outlook, I can see the connection is OK. All of this is happening in an internal network, so no O365 and such.



      PS: Please tell me if the question is more appropriate for superuser.com, I'll move it there if need be.









      share







      New contributor




      Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Is there any way to check if Outlook can successfully connect to Exchange from Powershell? I would like to schedule that script for logging purposes.



      After some research, I managed to cook up the following:



      $outlook = New-Object -ComObject Outlook.Application
      Start-Sleep -s 5

      $session = $outlook.session
      $inbox = $session.GetDefaultFolder([Microsoft.Office.Interop.Outlook.olDefaultFolders]::olFolderInbox)

      $date = Get-Date
      If ($session.Offline) {
      $output = "Fail, mode $($session.ExchangeConnectionMode.ToString())"
      } Else {
      $output = "Success"
      }
      "[$date] $output `n" | Out-File -Append "$HOMEol_log.txt" -Encoding "UTF8"
      $outlook.Quit()


      This writes "Success" even if I pull the cable. A different way to check I found is



      $validStates = "olCachedConnectedDrizzle", "olCachedConnectedDrizzle", "olCachedConnectedHeaders", "olOnline"
      if ($validStates -contains $session.ExchangeConnectionMode.ToString()) {...}


      ...which always fails, since connection mode here is olCachedDisconnected for some reason. If I manually open Outlook, I can see the connection is OK. All of this is happening in an internal network, so no O365 and such.



      PS: Please tell me if the question is more appropriate for superuser.com, I'll move it there if need be.







      powershell exchange outlook-2010





      share







      New contributor




      Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 mins ago









      AtmaksAtmaks

      1




      1




      New contributor




      Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Atmaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Atmaks is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964515%2fhow-to-check-if-outlook-can-connect-to-exchange-from-a-script%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Atmaks is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Atmaks is a new contributor. Be nice, and check out our Code of Conduct.













          Atmaks is a new contributor. Be nice, and check out our Code of Conduct.












          Atmaks is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f964515%2fhow-to-check-if-outlook-can-connect-to-exchange-from-a-script%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Фонтен-ла-Гаярд Зміст Демографія | Економіка | Посилання |...

          Список ссавців Італії Природоохоронні статуси | Список |...

          Маріан Котлеба Зміст Життєпис | Політичні погляди |...