Powershell on Windows TASK SCHEDULER
NickName:Leandro Brostolim Ask DateTime:2016-04-15T22:10:40

Powershell on Windows TASK SCHEDULER

Sorry for my bad english, I hope you understand me..

I have a PowerShell script to monitor CPU usage and script executing well on PowerShell command line. But when I schedule same script on Windows Task Scheduler, it start executing, but not respect parameters SampleInterval and MaxSamples. Like described on command below:

$Counter = @{
    Counter = "\Processor(_Total)\% user time", "\Processor(_Total)\% idle time", "\Processor(_Total)\% Processor Time", 
        "\System\Processor Queue Length", "\System\Context Switches/sec", "\System\System Calls/sec"
    SampleInterval = $intervalo
    MaxSamples = $amostra
    }

    $metrics = Get-Counter @Counter 

Copyright Notice:Content Author:「Leandro Brostolim」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/36649495/powershell-on-windows-task-scheduler

More about “Powershell on Windows TASK SCHEDULER” related questions

Issue Running PowerShell on Windows Task Scheduler

I'm trying to run a PowerShell command via Task Scheduler but keep getting the below result when the task tries to run PowerShell on my Windows Server 2008 R2 environment. action "powershe...

Show Detail

Windows Task Scheduler to execute .aspx page using Powershell

I want to use Windows Task Scheduler to execute my ASP.NET web page (.aspx). I read that Windows Powershell can help in this. The post asp.net script in task scheduler tells a command "powershell....

Show Detail

Issue with windows task scheduler with running a powershell script in windows 2008 server

This question would seem a very common question but i have done every possible thing for the solution but nothing works for me. I m trying to run a powershell script via batch powershell.exe c:\

Show Detail

Powershell on Windows TASK SCHEDULER

Sorry for my bad english, I hope you understand me.. I have a PowerShell script to monitor CPU usage and script executing well on PowerShell command line. But when I schedule same script on Window...

Show Detail

PowerShell script running as different user in Windows Task Scheduler

I am trying to configure a PowerShell script which will run in Windows Task Scheduler for multiple service accounts. I found a way to run the PowerShell script with a given user via the 2nd answer...

Show Detail

Unable to run a powershell script using Windows task scheduler

I have a simple powershell script to get the names in a directory and write it into a file . I want this to be executed daily at 8:00AM so I created a task for it from the Windows task scheduler the

Show Detail

Powershell and task scheduler

I am having a strange issue with task scheduler on my Win 7 machine not properly running a Powershell script which is supposed to email me a PDF file daily. If I run the script manually via ISE......

Show Detail

Windows Task Scheduler is not working on Cluster through powershell

I have configured the windows task scheduler with any node type using powershell commands in the cluster as Active/Passive. If one system goes down, the task scheduler is switching to another node ...

Show Detail

Windows Task Scheduler not returning $LASTEXITCODE from a Powershell script

I have a script that just calls Exit 1. But, when this script is run via Windows Task Scheduler, I get either a return code of 0, or 2147942401, but I never get the expected 1. Details below. Script

Show Detail

Windows scheduler not executing task

The below command-line will successfully execute a powershell command invisibly; saving the output to a text file: C:\Windows\System32\wscript.exe C:\temp\invisible.vbs C:\Windows\System32\

Show Detail