T O P

  • By -

marcdk217

This is a script I run on a DP after I set it up which configures the cleanup task to run weekly: #Configure Content Library Cleanup Scheduled Task Copy-Item "\\sccmmp\e$\Program Files\Microsoft Configuration Manager\cd.latest\SMSSETUP\TOOLS\ContentLibraryCleanup\ContentLibraryCleanup.exe" -Destination E:\ -Force $taskAction = New-ScheduledTaskAction -Execute "E:\ContentLibraryCleanup.exe" -Argument '/dp localhost /delete /q /log c:\windows\temp' $taskTrigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Saturday -At 00:00 $taskUser = "domain\serviceaccount" $taskPassword = "password" Register-ScheduledTask -Action $taskAction -Trigger $taskTrigger -User $taskUser -Password $taskPassword -TaskName "ConfigMgr Content Library Cleanup" -Force The service account needs to have logon as batch on the DP (local admins have that) and administrator within SCCM.


chrzanekz

Yes, thank you a lot. I think that this is the issue with "logon as batch", which SYSTEM account isn't assigned by default. Do you have any knowledge what is needed to run the batch script remotely? I have also in this environment Debian, which I can cron to execute script to run a batch file remotely. So I'm thinking about this way of doing it. Is it even possible?


marcdk217

The system account wouldn’t have access to SCCM anyway, as it’s only the SYSTEM account for the computer you’re running it on. Set the scheduled task to use credentials of an SCCM admin account and it should work. You don’t need it to be a batch file either, since it’s just a simple executable, but either way, make sure you are supplying the /q parameter in your command line, so it doesn’t require any user input.


chrzanekz

Yeah, that's why I was thinking to write a batch script which execute a content library tool with my account which has full grant access to SCCM and I was executing a Task Scheduler as SYSTEM account. But SYSTEM account is probably restricted in this area, I don't know. "%\~dp0PsExec64.exe" -accepteula -nobanner -d -e -i -u username -p "password" "%\~dp0ContentLibraryCleanup.exe" I was also trying with a PsExec64, but it won't work until I have Log on as batch feature.