Automation

 View Only
Expand all | Collapse all

scheduling_task

  • 1.  scheduling_task

    Posted Oct 08, 2019 02:22 PM

    Hi Luc,

    if yu could suggest something on following .

    one task has been scheduled to run health check script which runs fine but not getting report in provided path .



  • 2.  RE: scheduling_task

    Posted Oct 08, 2019 02:31 PM

    One thing you could check is the account under which the scheduled script runs.
    Does it have permission to write in that location?

    For further analysis I would need to see how the scheduled task is defined and how the script writes the report.



  • 3.  RE: scheduling_task

    Posted Oct 08, 2019 03:28 PM

    $user = 'xyz\user1'

    $pswd = 'password1'

    $sAction = @{

       Execute = 'Powershell.exe'

       Argument = '-NoProfile -WindowStyle Hidden -File c:\HC\hc.ps1'

    }

    $action = New-ScheduledTaskAction @sAction

    $sTrigger = @{

       Daily = $true

       At = '10:00am'

    }

    $trigger = New-ScheduledTaskTrigger @sTrigger

    $sTask = @{

       Action = $action

       Trigger = $trigger

       User = $user

       Password = $pswd

       TaskName = 'vfalpp_HC'

       Description = 'vfalpp_hc'

       RunLevel = 'Highest'

    }

    $task = Register-ScheduledTask @sTask

    above script is used to schedule task .

    xyz\user1  is part of domain admins and domain users .

    the script is health check powershelll script which runs fine in other clientaccounts .



  • 4.  RE: scheduling_task

    Posted Oct 08, 2019 03:55 PM

    That looks ok at first sight.

    Can you add a Start-Transcript to the actual healthcheck script?

    And perhaps add some debug lines with Write-Host in the script?



  • 5.  RE: scheduling_task

    Posted Oct 09, 2019 10:23 AM

    I am going to add

    Start-Transcript -Path C:\HC\Transcript.log

    at the very begining of the script however when i manullay run this script it works find and writing to c:\HC   folder.



  • 6.  RE: scheduling_task

    Posted Oct 09, 2019 10:49 AM

    There might be a prompt, or a missing permission, or ...
    The transcript might show where the problem is located.



  • 7.  RE: scheduling_task

    Posted Oct 09, 2019 10:56 AM

    I am not getting anything in that path if i schedule it through task.

    nither the ouputnot transcript.log .



  • 8.  RE: scheduling_task

    Posted Oct 09, 2019 11:07 AM

    Can you add a Write-Host with some text, after the Start-Transcript?
    That way we are sure the script is actually producing any out for the transcript.



  • 9.  RE: scheduling_task

    Posted Oct 09, 2019 11:16 AM

    i am checking this.



  • 10.  RE: scheduling_task

    Posted Oct 09, 2019 04:16 PM

    for some reasons write-host is not being displayed on console though i can see  transcript.log

    however i dont see any report in the specified path .

    hope there is no background task being run to delete that file.



  • 11.  RE: scheduling_task

    Posted Oct 09, 2019 04:38 PM

    The Write-Host should indeed go to the transcript log.


    Do a Get-ChildItem before and after you create the file, then we can at least be sure the file is created.



  • 12.  RE: scheduling_task

    Posted Oct 10, 2019 09:52 AM

    i am checking this .



  • 13.  RE: scheduling_task

    Posted Oct 10, 2019 11:52 AM

    well i have write-host just after start-transcript ...

    and i can now see text being written on console..

    however no report being generated .



  • 14.  RE: scheduling_task

    Posted Oct 10, 2019 11:55 AM

    I was mentioning getting a directory content listing of the target directory (where the report should go) with Get-ChildItem.

    Just before and after you create the report.



  • 15.  RE: scheduling_task

    Posted Oct 11, 2019 10:03 AM

    I have already checked this there are only 2 files in that path .no htmlreport before and after .



  • 16.  RE: scheduling_task

    Posted Oct 11, 2019 10:05 AM

    Can you attach the script as a file?

    I would like to do a test run in my lab.



  • 17.  RE: scheduling_task

    Posted Oct 11, 2019 10:28 AM

    i have attached the  beautiful script .



  • 18.  RE: scheduling_task

    Posted Oct 11, 2019 03:46 PM

    That seems to be a double-byte format.
    Would it possible to attach it in a single-byte format?



  • 19.  RE: scheduling_task

    Posted Oct 14, 2019 06:11 AM

    if you could suhhest some article to send in single byte format as i have not done this in past..



  • 20.  RE: scheduling_task

    Posted Oct 14, 2019 06:42 AM

    Open the file in for example notepad, then make sure to save it in UTF-8 format.



  • 21.  RE: scheduling_task

    Posted Oct 28, 2019 02:23 PM

    hi luc ,

    was on leave .however scheduled task to run this script is working now .

    thanks.