Reputation: 11
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
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