Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

PENDING Windows Schedule Task to clear machines in collection

craigegross

Member
Messages
9
Reaction score
0
Points
1
I am trying to set up a scheduled task to clear a collection and set that task to run as a scheduled task kicked off by either Windows Task Scheduler or SQL Server Agent.

I have a script that will create the connection to the CM instance and removes the machines from the collection when I run it through an elevated PowerShell script, but when I set it up to run as a scheduled task, the task completes successfully, but the machines do not get removed.

I am running this in the task "PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "\Share\CM_Scripts_DND\CM_Machine_Dupe_Cleanup.ps1""

The task is set to run as a service account that has permissions to CM.

I am unsure if the issue is permissions or what.

Any ideas would be helpful.
 
Add logging to you script. Why host the ps1 file remotely from the server? What account are you running the TS as?
 
The PS file isn't remote - it is on the server - just using a share location for permissions.

The account running the tasks is a Service Account that had rights to the server and the SCCM instance.

Hope that answers those two questions.
 
Back
Top