pjzapped
pjzapped

Reputation: 11

Task scheduler Windows 10

I guess this is easy but is eluding me, I have a working Powershell script that I wish to run as a Scheduled Task in Windows 10, however the script does not execute from the Task scheduler.

Script is hider.ps1

$fs = New-Object -ComObject scripting.filesystemobject
Get-ChildItem "D:\TV Shows\" -force | Where-Object {$_.psiscontainer} | ForEach-Object {
    if($fs.getfolder($_.fullname).size -lt 20mb) {$_.attributes = "directory,hidden"}
    else{$_.attributes = "directory"}
}

This hides empty folders in a directory

In Task scheduler I have put

Start a program Powershell

Arguments -ExecutionPolicy Bypass –File "F:\Xaved Files\Hider ps 1"

Upvotes: 1

Views: 3783

Answers (1)

Raul Luna
Raul Luna

Reputation: 2046

Have you set the "start in" directory???

Apparently, since windows server 2012, if a task doesn't have this field informed, the task doesn't run silently.

This worked in my case, and also to this guy

Upvotes: 2

Related Questions