Automation

 View Only
Expand all | Collapse all

Powershell Script Email Sending Issue

  • 1.  Powershell Script Email Sending Issue

    Posted Apr 24, 2019 07:21 AM

    I have an issue with schedule the power shell script

    HTML report is not showing complete out put with schedule

    HTML report shows properly if I trigger manually

    Exchange 2016 with SMTP



  • 2.  RE: Powershell Script Email Sending Issue

    Posted Apr 24, 2019 07:50 AM

    You will have to provide a bit more info on this.
    What script are you using?
    How are you scheduling it?
    What exactly is missing?



  • 3.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 06:20 AM

    What script are you using? - vCheck Report    

    How are you scheduling it?  Program Powershella nd argument as  -file "C:\Scripts\vCheck-vSphere-master\vCheck.ps1"

    What exactly is missing? -  not showing any output of scripts only the shows below info  , if we ran manually the scripts from powershell / vsphere cli it gives output

    • General Information
    • vSwitch Security
    • VMs by Operating System
    • Plugin Report

    General Information

    General details on the infrastructure

    Number of Hosts:

    1

    Number of Templates:

    1

    In-active VMs:

    0

    Number of Datastores:

    1

    Active VMs:

    0

    Number of Clusters:

    1

    Number of VMs:

    1

    DRS Migrations for last 1 Days:

    0

    Back To Top

    vSwitch and portgroup security settings

    All security options for standard vSwitches should be set to REJECT. Distributed vSwitches may require ForgedTrasmits in the default portgroup but should be disabled in other VM Network portgroups unless expressly required.

    Message

    PowerCLi version installed is lower than 5.1 Release 2, please update to use this plugin

    Back To Top

    VMs by Operating System : 1

    The following Operating Systems are in use in this vCenter

    OS

    Count

    Unknown - no VMTools

    1

    Back To Top

    Plugin Report

    Plugins in numerical order, enabled plugins listed first



  • 4.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 06:30 AM

    Under which account does the scheduled task run?

    How do you connect to the vSphere Server in the scheduled task? VICredentialStoreItem, hard-coded...?

    Did you suppress all 'interactivity'? For example did you disable Depreciation Warning message?

    Is there any reason why you are using that rather old PowerCLI version?
    That is what the VDS plugin is telling you.

    To allow the plugin to detect the guest OS name, requires that VMware Tools are installed inside the guest OS.
    Apparently they aren't on the VM you tested against.



  • 5.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 06:45 AM

    Under which account does the scheduled task run? - one service account

    How do you connect to the vSphere Server in the scheduled task? VICredentialStoreItem, hard-coded...? no the account has access to vcenter when it runs automatically connects

    Did you suppress all 'interactivity'? For example did you disable Depreciation Warning message?   - yes

    Is there any reason why you are using that rather old PowerCLI version?  - it was configured earlier not changed , it was working  recently there exchange migration happened 2010 to 2016 and this issue started and they cannot find a reason / fix
    That is what the VDS plugin is telling you. -  how to use instead of old PowerCLI

    To allow the plugin to detect the guest OS name, requires that VMware Tools are installed inside the guest OS.
    Apparently they aren't on the VM you tested against.     - Tools are available



  • 6.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 08:17 AM

    Let's take this step by step.
    Can you first check that sending an email is working, from an interactive session and from a scheduled job?

    Use something like the following to perform the tests.

    $sMail = @{

       To = 'you@domain'

       From = 'me@domain'

       Subject = 'Test Email'

       SmtpServer = 'mail.domain'

    }


    Send-MailMessage @sMail



  • 7.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 10:59 AM

    Yes it is working fine .

    When I ran vcheck from vsphere cli I will get complete report in html to mail



  • 8.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 11:23 AM

    "Yes it is working fine ." -> You mean from a scheduled job?



  • 9.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 11:57 AM

    Manual working fine from power cli

    schedule not working



  • 10.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 12:21 PM

    Ok, we can conlcude that there is an issue with sending mail via SMTP to the mail server with the account the scheduled task is using.

    You said earlier that the scheduled task uses a system account, can you try with the account you use to run the script in interactive mode?



  • 11.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 12:28 PM

    Schedule of test mail works now , just I deleted and create task again .



  • 12.  RE: Powershell Script Email Sending Issue

    Posted Apr 24, 2019 04:47 PM
    Send the script to see where the problem is


  • 13.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 06:21 AM

    Script working fine only through schedule it gives error , its vcheck report



  • 14.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 12:30 PM

    How are you scheduling it? For the action you should call powershell.exe and then for the arguments you should have -ExecutionPolicy bypass -File C:\path\to\vcheck.ps1. You also want to make sure that you are letting the schedule run while the user isn't logged in, but don't check the do not store password, as I've had problems with the vcheck . They should look kinda like this

    I've seen that report blank out like that if you don't have the scheduled task setup correctly.



  • 15.  RE: Powershell Script Email Sending Issue

    Posted Apr 25, 2019 02:12 PM

    Thanks , it worked



  • 16.  RE: Powershell Script Email Sending Issue

    Posted Apr 28, 2019 06:15 AM

    It works only when ran manually from schedule task , automatic schedule still not shows