VMware Cloud Community
jvm2016
Hot Shot
Hot Shot

scheduling_task

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 .

pastedImage_0.png

Reply
0 Kudos
20 Replies
LucD
Leadership
Leadership

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

$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 .

Reply
0 Kudos
LucD
Leadership
Leadership

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?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

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.

Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

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

nither the ouputnot transcript.log .

Reply
0 Kudos
LucD
Leadership
Leadership

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

i am checking this.

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

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.

Reply
0 Kudos
LucD
Leadership
Leadership

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

i am checking this .

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

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

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

however no report being generated .

Reply
0 Kudos
LucD
Leadership
Leadership

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

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

Reply
0 Kudos
LucD
Leadership
Leadership

Can you attach the script as a file?

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

i have attached the  beautiful script .

Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

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

Reply
0 Kudos
LucD
Leadership
Leadership

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

utf8.jpg


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos