Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New command] Test-DbaScheduledTask, #828

Closed
MARCO-K opened this issue Feb 24, 2017 · 13 comments
Closed

[New command] Test-DbaScheduledTask, #828

MARCO-K opened this issue Feb 24, 2017 · 13 comments

Comments

@MARCO-K
Copy link

MARCO-K commented Feb 24, 2017

Is this a feature OR bug:

This is a new feature.

Details

Basically the cmdlet verifies if ScheduledTask state is configured accorind the Windows-based best practice.

The intention of this new command is to verify the state of the scheduled taks "ScheduledDefrag". I had huge performance hits causing SQL iserver to slow down a lot with the task enabled.

@potatoqualitee
Copy link
Member

I'm intrigued :) How would we test that the scheduled tasks state is best practice?

@MARCO-K
Copy link
Author

MARCO-K commented Feb 24, 2017

Hi,

it's simply comparing:
$bpState = 'Disabled'
$taskname = 'ScheduledDefrag'
$task = Get-ScheduledTask | Where-Object Taskname -eq $taskname
$task.State -eq $bpState

I've already created the script and doing some testing now.

@potatoqualitee
Copy link
Member

I'm digging it. Any others on that list?

Remember, though, that we write for PS 3 which does not include Get-ScheduledTask.

You'll have to use New-Object -ComObject Schedule.Service or something similar

@MARCO-K
Copy link
Author

MARCO-K commented Feb 24, 2017

jsut started with the defrag because i had performance problems quite recently.

Thanks. for the advice. I'll change it in my script.

@wsmelton
Copy link
Member

wsmelton commented Feb 24, 2017

The only issue with this is that task is not a standard for Windows OS. Basically, you will never find a scheduled task on a given server called "ScheduledDefrag" or anything else because it is not there by default. The only way that task exist is if you happen across an environment that someone created it with the exact same name. So looking for that name specifically is not going to work.

You might be able to look at task that are calling defrag utility, but not sure that will be 100% accurate either...there are many 3rd party apps that monitor and handle defrag as well.

@potatoqualitee
Copy link
Member

I had checked this and it is there by default -- this is on my fresh 2016 box

image

@MARCO-K
Copy link
Author

MARCO-K commented Feb 24, 2017

In fact this jobs is enabled by default since 2012. That was cause a lot of trouble for me.

@niphlod
Copy link
Contributor

niphlod commented Feb 24, 2017

@niphlod
Copy link
Contributor

niphlod commented Feb 24, 2017

And suggesting disabling for everyone as a defacto standard isn't a smart choice... defragging still needs to be done to avoid slowly crawling performances.

@niphlod
Copy link
Contributor

niphlod commented Feb 24, 2017

tl;dr: run defrag.exe -c -h -k -g -$ and see it exiting instantaneously almost everywhere.

@wsmelton
Copy link
Member

This is strictly my opinion, but I have been in multiple high-end environments that were doing millions of transactions a second for online sites. I have never had to disable this scheduled task, and likely would never do so.

That task itself is hidden, you cannot visibly access it using Task Scheduler and the only way to even disable it that I can find is from command line.

In the years I have been support SQL Server since 2012 OS came out I have never come across this scheduled task being an issue. I also do not believe it is best practice to disable that task, MS put it there for a reason. If you believe it is best practice then you need to come up with an authoritative reference stating as such. In that sense I would not make any mention of this being best practice unless it can be shown that it is a recommended practice from either MS or the community.

@niphlod
Copy link
Contributor

niphlod commented Mar 13, 2017

going to close this in a few days if @MARCO-K got what we are telling (which is, basically, that task isn't definitely a bad practice)

@potatoqualitee
Copy link
Member

agreed, thanks you guys for the feedback and taking the time to explain!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants