Powershell scripting advice on disabling Services and tasks

Col_Temp

Weaksauce
Joined
Jun 1, 2020
Messages
101
Hi all,
Not sure if this is exactly the right place for this. If not Mods please move it.

So here is the problem I've got. Windows is getting slower again with all the stupid update services, tasks, and general garbage running int he background.
What I would like to do is set up a script in Powershell (probably the best) that would:
I have automated updates planning in place that only run updates once the update is approved higher up. That way updates don't get deployed that cause messes!

1. Find the stupid Adobe Reader update service and turn it off and set to disabled.
2. Find the Adobe Flash service and do the same turn off and disable.
3. Find the Google Update service and stoip and disable.
4. Find the Mozilla update service and do the same.
5. That finds the enabled task scheduler task that runs the stupid Google update every hour and disables it.
6. Does the same for the adobe update task in scheduler.
7. Does the same for One drive updater.
8. checks the defrag is off (can be done from scheduled tasks.)
9. Turns off the skype service and startup item.

Would be nice to be able to pass a variable with any other service or task. Figure once the base script is done most of these are duplicates of the first with the service or task name changed.

Any experts out there who could help?
Thanks
 
  • Like
Reactions: x509
like this

x509

2[H]4U
Joined
Sep 20, 2009
Messages
2,209
As long as we are compiling a "wish list," I would like to hibernate all the systems in my house at midnight.

Honestly, I should have already learned PS myself. .
 

socK

2[H]4U
Joined
Jan 25, 2004
Messages
3,973
Hi all,
Not sure if this is exactly the right place for this. If not Mods please move it.

So here is the problem I've got. Windows is getting slower again with all the stupid update services, tasks, and general garbage running int he background.
What I would like to do is set up a script in Powershell (probably the best) that would:
I have automated updates planning in place that only run updates once the update is approved higher up. That way updates don't get deployed that cause messes!

1. Find the stupid Adobe Reader update service and turn it off and set to disabled.
2. Find the Adobe Flash service and do the same turn off and disable.
3. Find the Google Update service and stoip and disable.
4. Find the Mozilla update service and do the same.
5. That finds the enabled task scheduler task that runs the stupid Google update every hour and disables it.
6. Does the same for the adobe update task in scheduler.
7. Does the same for One drive updater.
8. checks the defrag is off (can be done from scheduled tasks.)
9. Turns off the skype service and startup item.

Would be nice to be able to pass a variable with any other service or task. Figure once the base script is done most of these are duplicates of the first with the service or task name changed.

Any experts out there who could help?
Thanks

I don't have any Adobe stuff or Chrome installed on my machine so I'm just guessing their services start with Adobe and Google respectively.

Bash:
$services =
@(
    "Adobe*",
    "Google*",
    "Mozilla*"
)

Get-Service $services | Stop-Service $services

$tasks =
@(
    "Adobe*",
    "OneDrive*",
    "Firefox*",
    "ScheduledDefrag"
)

Get-ScheduledTask $tasks | Disable-ScheduledTask
 

socK

2[H]4U
Joined
Jan 25, 2004
Messages
3,973
As long as we are compiling a "wish list," I would like to hibernate all the systems in my house at midnight.

Honestly, I should have already learned PS myself. .

You may run into Remote UAC issues and some other annoyances if you're logging in as a local account. Not entirely sure the code is correct, I generally never do remoting on non-domain joined machines.
https://support.microsoft.com/en-us...nt-control-and-remote-restrictions-in-windows

This one's tricky just because you need to jump through some hoops.

You might need to run something like once on your machines you're connecting to... completely untested, I'm just winging it.

Bash:
$regArgs =
@{
    Path         = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
    Name         = "LocalAccountTokenFilterPolicy"
    PropertyType = "DWORD"
    Value        = 1
}

New-ItemProperty @regArgs

Set-Item "WSMan:\localhost\Client\TrustedHosts" -Value "MACHINE_YOURE_REMOTING_FROM" -Force
Enable-PSRemoting -Force
winrm quickconfig


Then, assuming you can connect, this is what you'd run/schedule on the machine that will be shutting everything down... again, I'm half taking a stab in the dark.

Bash:
$computers =
@(
    "UR_COMPUTER_NAME",
    "SOME_OTHER_NAME",
    "ASDJLASDKD"
)
$credential = [PSCredential]::new("YOUR_LOCAL_USERNAME", (ConvertTo-SecureString "THE_PASSWORD_FOR_IT" -AsPlainText -Force))
Invoke-Command $computers -Authentication Negotiate -ScriptBlock {
    shutdown.exe /h
}
 

Col_Temp

Weaksauce
Joined
Jun 1, 2020
Messages
101
Thanks for the tips. Going to work on them. Nice thing is I have a way to remote execute this stuff as the admin or through the system account.
Thanks for the warning going to try it on my machine first and see. This is kind of what I needed to get started. Been too long since I had to do this. But with about 100 customer machines It will take way to long to fix this one by one.
Plus we have Mircosoft, Adobe, Google, and several others turning things back on everytime whether you want them to or not!
 

socK

2[H]4U
Joined
Jan 25, 2004
Messages
3,973
Don't hesitate to feed me PowerShell script requests or questions, I'm a PowerShell warlord and live for this
 
Top