diff --git a/apps/exchange/2010/local/mode/imapmailbox.pm b/apps/exchange/2010/local/mode/imapmailbox.pm index 266ab55d0..1f4e85bfe 100644 --- a/apps/exchange/2010/local/mode/imapmailbox.pm +++ b/apps/exchange/2010/local/mode/imapmailbox.pm @@ -33,22 +33,22 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "remote-host:s" => { name => 'remote_host', }, - "remote-user:s" => { name => 'remote_user', }, - "remote-password:s" => { name => 'remote_password', }, - "no-ps" => { name => 'no_ps', }, - "timeout:s" => { name => 'timeout', default => 50 }, - "command:s" => { name => 'command', default => 'powershell.exe' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, - "ps-exec-only" => { name => 'ps_exec_only', }, - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, - "mailbox:s" => { name => 'mailbox', }, - "password:s" => { name => 'password', }, - }); + $options{options}->add_options(arguments => { + "remote-host:s" => { name => 'remote_host', }, + "remote-user:s" => { name => 'remote_user', }, + "remote-password:s" => { name => 'remote_password', }, + "no-ps" => { name => 'no_ps', }, + "timeout:s" => { name => 'timeout', default => 50 }, + "command:s" => { name => 'command', default => 'powershell.exe' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, + "ps-exec-only" => { name => 'ps_exec_only', }, + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, + "mailbox:s" => { name => 'mailbox', }, + "password:s" => { name => 'password', }, + }); + return $self; } @@ -85,7 +85,7 @@ sub run { remote_user => $self->{option_results}->{remote_user}, remote_password => $self->{option_results}->{remote_password}, mailbox => $self->{option_results}->{mailbox}, - password => $self->{option_results}->{password}, + password => $self->{option_results}->{password}, no_ps => $self->{option_results}->{no_ps}, ); $self->{option_results}->{command_options} .= " " . $ps; @@ -173,4 +173,4 @@ Set the password for the mailbox (Required). =back -=cut \ No newline at end of file +=cut diff --git a/apps/exchange/2010/local/mode/outlookwebservices.pm b/apps/exchange/2010/local/mode/outlookwebservices.pm index b0af52d65..f82d3b663 100644 --- a/apps/exchange/2010/local/mode/outlookwebservices.pm +++ b/apps/exchange/2010/local/mode/outlookwebservices.pm @@ -33,21 +33,22 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "remote-host:s" => { name => 'remote_host', }, - "remote-user:s" => { name => 'remote_user', }, - "remote-password:s" => { name => 'remote_password', }, - "no-ps" => { name => 'no_ps', }, - "timeout:s" => { name => 'timeout', default => 50 }, - "command:s" => { name => 'command', default => 'powershell.exe' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, - "ps-exec-only" => { name => 'ps_exec_only', }, - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', default => '%{type} !~ /Success|Information/i' }, - "mailbox:s" => { name => 'mailbox', }, - }); + $options{options}->add_options(arguments => { + "remote-host:s" => { name => 'remote_host', }, + "remote-user:s" => { name => 'remote_user', }, + "remote-password:s" => { name => 'remote_password', }, + "no-ps" => { name => 'no_ps', }, + "timeout:s" => { name => 'timeout', default => 50 }, + "command:s" => { name => 'command', default => 'powershell.exe' }, + "command-path:s" => { name => 'command_path' }, + "command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, + "ps-exec-only" => { name => 'ps_exec_only', }, + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', default => '%{type} !~ /Success|Information/i' }, + "mailbox:s" => { name => 'mailbox', }, + "password:s" => { name => 'password', }, + }); + return $self; } @@ -81,6 +82,7 @@ sub run { remote_password => $self->{option_results}->{remote_password}, no_ps => $self->{option_results}->{no_ps}, mailbox => $self->{option_results}->{mailbox}, + password => $self->{option_results}->{password}, ); $self->{option_results}->{command_options} .= " " . $ps; my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, @@ -161,6 +163,10 @@ Can used special variables like: %{type}, %{id}, %{message} Set the mailbox to check (Required). +=item B<--password> + +Set the password for the mailbox. + =back -=cut \ No newline at end of file +=cut diff --git a/centreon/common/powershell/exchange/2010/imapmailbox.pm b/centreon/common/powershell/exchange/2010/imapmailbox.pm index bcdcd9e64..92b494f30 100644 --- a/centreon/common/powershell/exchange/2010/imapmailbox.pm +++ b/centreon/common/powershell/exchange/2010/imapmailbox.pm @@ -120,4 +120,4 @@ __END__ Method to check Exchange 2010 imap on a specific mailbox. -=cut \ No newline at end of file +=cut diff --git a/centreon/common/powershell/exchange/2010/outlookwebservices.pm b/centreon/common/powershell/exchange/2010/outlookwebservices.pm index 47bd736ce..336e0c03f 100644 --- a/centreon/common/powershell/exchange/2010/outlookwebservices.pm +++ b/centreon/common/powershell/exchange/2010/outlookwebservices.pm @@ -36,8 +36,23 @@ sub get_powershell { $ps .= ' try { - $ErrorActionPreference = "Stop" + $ErrorActionPreference = "Stop" +'; + if (defined($options{password}) && $options{password} ne '') { + $ps .= ' + $username = "' . $options{mailbox} . '" + $password = "' . $options{password} . '" + $secstr = New-Object -TypeName System.Security.SecureString + $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} + $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr + $results = Test-OutlookWebServices -WarningAction:SilentlyContinue -MailboxCredential $cred +'; + } else { + $ps .= ' $results = Test-OutlookWebServices -WarningAction:SilentlyContinue -Identity "' . $options{mailbox} . '" +'; + } + $ps .= ' } catch { Write-Host $Error[0].Exception exit 1 @@ -107,4 +122,4 @@ __END__ Method to check Exchange 2010 outlook autodiscovery webservices. -=cut \ No newline at end of file +=cut