Automate your PowerShell scripts with Windows Task Scheduler
Ғылым және технология
In this video you will learn how to save your PowerShell cmdlets as a PS1 file and then run that PS1 file as a scheduled task. Pretty cool stuff. Short and to the point keeping you moving forward on your PowerShell skills journey.
Here is the code from the script if you need it:
Get-Date | Out-File E:\Demo\log4video.txt -Append
Get-PSDrive -PSProvider FileSystem | Out-File E:\Demo\log4video.txt -Append
Video on creating useful CSV files
• PowerShell Arrays Intr...
Video on using Get-Date
• Work with Date & Time ...
BONUS: This video shows you how to create the task with PowerShell
• PowerShell create a sc...
If you need more PowerShell help you can always contact me via www.BoldZebras.com
Пікірлер: 210
Loves your channel, it's a real help in entering the Powershell world.
Thanks Shane, perfect working example ‘beginners intro’ to Windows Task Scheduler!
@ShanesCows
2 жыл бұрын
Glad it was helpful!
Good to see the way of sorting everything easily...
@ShanesCows
5 жыл бұрын
😀
I was struggling with bat files to run a simple p.shell script on task scheduler. Thanks a lot for this helpful video.
@ShanesCows
3 жыл бұрын
Glad it was helpful!
Hi Shane, you've done the great job again. This is the mystery Kenny. The video is very helpful as usual. Many thanks and keep up the great work.
@ShanesCows
6 жыл бұрын
Hopefully, it nailed it for you. :) Great idea for a topic. Keep them coming. Thank you! Shane
@kennyjide2933
6 жыл бұрын
Yes it did nail it for me. Thanks again
@ShanesCows
6 жыл бұрын
Hey. I just made a video on how to create the scheduled task with PowerShell to finish the circle. :) kzread.info/dash/bejne/m66gq6yNnbi9YNI.html
You're the best Shane! Thanks for all your amazing videos :)
@ShanesCows
4 жыл бұрын
Glad to help. 😀
Love your tutorials and I'm new at this! Can you share how to do a full and incremental backup using PowerShell for simple folder backup? Thank you!
Yet, again Shane. Thanks for your vids. Its thru your vids where I was able to learn powershell for work. Ah, to add though, In the Actions part: I'd suggest to add: ' -command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Force" ' in the arguments part since there are times the script wont be able to run because execution policies restrictions.
@ShanesCows
3 жыл бұрын
Thanks for sharing 😎
Thanks a lot man help me out loads
@ShanesCows
4 жыл бұрын
Glad to help. 😀
Thanks mate, that's realy cool
@ShanesCows
2 жыл бұрын
Awesome :)
You da man! This video was awesome. New sub B^)
@ShanesCows
Жыл бұрын
Awesome, thank you!
Many thanks, it helped me. :)
@ShanesCows
5 жыл бұрын
Great! 👍
Thanks Shane !
@ShanesCows
3 жыл бұрын
Happy to help Ram
great video! love it
@ShanesCows
4 жыл бұрын
Thanks 🙏
thanks Shane... this is exactly what I needed.... thanks for making it simple
@ShanesCows
3 жыл бұрын
Glad it helped!
@valeriem6475
3 жыл бұрын
@@ShanesCows Hi Shane.. I'll keep you in my back pocket... as I am a DBA that is trying to pretend I know how to use PS lol... don't let out my secret.
Thank you for the Video
@ShanesCows
Жыл бұрын
You're welcome
Thanks Shane for this lovely and simple to understand intro to executing PS script from windows task scheduler. I am completely new to PS scripting so please bear with me. From this video, I noticed that when setting up the "Action" tab, you did not use the syntax "-File" before the path to where your PS1 script (Add arguments (Optional)) is located. Though i have seen other forum and videos specified the use of this. Are you able to explain when you might need to use this please? Also, I am looking for an intro to subject incorporating the task scheduler whereby new files are monitored via PS scripts and send notification via emails on scheduled timetable. Would you have such video in your gallery please? Many thanks|!
@ShanesCows
3 жыл бұрын
I don't, sorry 😐
Loved the content and your personality, made it fun. Hope dinner was good! :-)
@ShanesCows
4 жыл бұрын
It was, thanks. Which K are you a fan of? Wildcats? Jayhawks?
@kodkid
4 жыл бұрын
Shane Young University of Kentucky Wildcats!
@ShanesCows
4 жыл бұрын
Awesome. I grew up a UK basketball fan. My family bleeds blue.
It works. Thanks a lot!!!
@ShanesCows
4 жыл бұрын
Glad to help. 😀
nice and simple staff...thanks Shane, you are the best....
@ShanesCows
4 жыл бұрын
Glad to help. 😀
Well I just discovered your channel here. Interesting.
This was the answer I was looking for. Thank you :)
@ShanesCows
3 жыл бұрын
Glad to help. 😀
Guides to us super and Tqx.
Thanks man! Exactly what I needed.
@ShanesCows
2 жыл бұрын
Awesome 😎
You were a big help! Thanks!
@ShanesCows
5 жыл бұрын
Cool
With all respect, you are the best.. Please upload more video about PowerShell scripts. Start from A to Z... I like how you demonstrate .. Heeeeeeeeer is our intro :) ... Thank you
@ShanesCows
6 жыл бұрын
Thank you. I promise at least one more PowerShell script this week. :) Creating AD users from a CSV.
Thank you!
@ShanesCows
3 жыл бұрын
Glad to help. 😀
'That's right, dedication here, we are making this video on a saturday', take your like good sir.
@ShanesCows
3 жыл бұрын
I am here for you guys 😎
Thank you Bro!
@ShanesCows
3 жыл бұрын
Happy to help
Hi Shane, not sure if you check old comments but here goes. I've got a parameterised PS script with a username and password that I want automated but I don't want to have my password in plain text within my script for security reasons. Any tips about this? Thanks, great video.
Thanks!!
shane.... u r a coolman!!
@ShanesCows
4 жыл бұрын
Thank you :)
every 10 mins d b scheduler pops up and it ruins my gaming, i try deleting it and stopping it and everything on task scheduler and no matter what i do it comes back, i dont know what to do
Hello Shane! Awesome videos - I'm learning a lot from you! :) Would like to ask how can I get multiple output files so everytime the task runs my powershell script via task manager, it won't overwrite the existing one? I am trying to get the list of logged in users in the RDS server per hour. So I need a new output file everytime the task runs. Is that possible? Thank you so much! :)
@ShanesCows
3 жыл бұрын
Use the Out-File cmdlet and don't select Append
Shane can you make a video on how to ping multiple machines and get the services of the machines like windows uptime and windows update in powershell
@ShanesCows
2 жыл бұрын
Sorry haven’t done that one
Thanks man!, this video really help me!
@ShanesCows
2 жыл бұрын
Glad to hear it!
Shane, Can we get email notification from Powershell if newer version of Adobe Flash player(Activex and NPAPI), Google Chrome, Mozilla Firefox ESR and Adobe acrobat reader release
@ShanesCows
3 жыл бұрын
I don't know... sorry
What if the location from the ps1 scrip is in another server, should I use as argument \\servername\folder\.ps1 or how should I put there? Thank you in advance.
@ShanesCows
9 ай бұрын
Sorry, been too long since I played with this give you a solid answer.
I subscribed simply because you're a very good tutor.
@ShanesCows
5 жыл бұрын
Thank you for the kudos.
nice and simple...just managed to automate a task that saves me 10-15 minutes daily
@ShanesCows
5 жыл бұрын
PERFECT!
Hi, if i have 11 ps1 file how can i run it everyday, how to write it?
hi Shane i have been trying to copy folders in the same way but it is not working for me so i have just copied exactly what you have done and it is not completing the script both your script and mine both work if i just run them in powershell would you have any suggestions as i am new to powershell and task scheduler and can't help but think i am missing something simple sorry and thanks in advance if you can
@ShanesCows
3 жыл бұрын
Hey Dave. I wish I had an answer. I haven't worked on PowerShell like this in so long. Maybe check out www.powershell.org I think they have a community that can help.
Hi save option is greyed out for me - any idea why? Thanks
Solve a BIG issue with automation... as I was using a cmd file to launch the ps files and it stopped working. Thank you.
@ShanesCows
4 жыл бұрын
Glad to help. 😀
Heyy do you know how to run shutdown program at certain time Let just say for 8 hours. So evertime somwone turn on the PC it will turn off automatically.
@ShanesCows
3 жыл бұрын
I don’t sorry
Hi Shane for me everything working task is being creating but whenever it run it didn't show the file updated as if not run
@ShanesCows
3 жыл бұрын
Not sure. Sorry
Hi pls do the video to run schedular jobs automatically using powershell script.
@ShanesCows
4 жыл бұрын
Sorry never done it.
What if I want to run the script with Admin rights? any way to pass that cmdlet into Task Scheduler rather than inserting it into the script itself.
@ShanesCows
3 жыл бұрын
I am not sure 🤔
yo good deal. thanks a alot. how about power shell windows update scheduled via task scheduler not gp
@ShanesCows
5 жыл бұрын
That would be cool
Thanks lot Shane.it saved my time.
@ShanesCows
3 жыл бұрын
Glad to help. 😀
Thank you for the video! You are a genius!
@ShanesCows
2 жыл бұрын
Glad you liked it!
Hi Shane, Do you have something to run a task scheduler job from task scheduler job?
@ShanesCows
5 жыл бұрын
Never tried. Sorry.
@vivekpathak5757
5 жыл бұрын
@@ShanesCows I just don't want to stop a task scheduler job , I also tried triggers in the task, yes that is working but saw pathetic history of task scheduler task like warning and failed error. Do you have something for.
It is possible to run powershell with admin access from task scheduler?
@ShanesCows
3 жыл бұрын
I think so but have never tried.
Hi.. Please help in how to write script in powershell which can trigger birthday / anniversary email from outlook on daily basis when the event occurs
@ShanesCows
4 жыл бұрын
Sorry haven’t done that.
@fayyazali2217
4 жыл бұрын
I now have script which can trigger email however unable to trigger from windows task scheduler. is there any way if I can trigger any task without login?
Thanks
@ShanesCows
3 жыл бұрын
You are welcome 🤗
Hi Sir, How can I use power shell to write down PC Lock time and PC unlock time in any of the text applications?
@ShanesCows
3 жыл бұрын
I don’t know. Sorry
@pankajshinde6205
3 жыл бұрын
It's okay sir
When I do this it says, running, but never finishes. Heard somewhere that you need to do something with the Set-ExecutionPolicy cmdlet. Any ideas?
@ShanesCows
4 жыл бұрын
Not sure. Sorry
Does this also work if powershell HAVE to be opened as an administrator?
@ShanesCows
3 жыл бұрын
I don't think it has to be. Just depends on what you need access to.
I am currently working on Auto-mailer reports, Your a #Live #Saver . Keep it up Shane.
@ShanesCows
4 жыл бұрын
Glad to help. 😀
So if I'm running exchange 2010 SP3 I can run the script in power shell not the exchange management shell? I'm trying to get an export of a user's calendar and contacts with a time stamp in the file name. Can you assist or do you have a video that covers that already?
@ShanesCows
5 жыл бұрын
I don’t sorry. I haven’t touched Exchange on Prem in a long time
@asnyc01
5 жыл бұрын
@@ShanesCows Thank you for your reply.
I want to put an alert email when a particular task success/fails and last run time of that task scheduled by task scheduler . Help me please
@ShanesCows
3 жыл бұрын
I haven’t done that before. Sorry
@StupidLostSoul-pu5xy
3 жыл бұрын
try to implement that also , it will be good
I have a set of weather report sounds (from JARVIS), so i want to hear the current weather report when i turn ON my computer from my custom sounds. So can u help me out?
@ShanesCows
4 жыл бұрын
Sorry, not something I have done before.
how can i set it for every 5 mins ??
is that the gobblegum machine from black ops 3 in the background?
@ShanesCows
5 жыл бұрын
No but that would be cool.
I Need some help. At work i am requiered to audit 300 machines so i go to eEvent Viewer/windows logs/security then i save the security file. Can you help me to automate this. v.r. Rick
@ShanesCows
5 жыл бұрын
Sorry Rick I haven’t done anything like that.
hi Shane, i dont want my script to run on Saturday and Sunday , what could i do possibly.
@ShanesCows
4 жыл бұрын
The tool has a lot of scheduling flexibility. I am sure you can make a schedule to do this.
Lovely video Shane, can you help me with script to ping multiple ip address and send the output to outlook 365 and schedule it run every day 6am. Pls
@ShanesCows
4 жыл бұрын
Never done it. Sorry
Tq bro
Hi, I have a task for PowerApps when the application starts, I need to get information about the computer from which the application is launched. Is it possible to use Power Shell (script) + Power Automate + Power Apps ... if it is technically possible, tell me where to look or maybe there is an opportunity and you will share the script like this :)
@ShanesCows
3 жыл бұрын
I haven't done this before. And sadly I don't even have a good guess of where to tell you to look to start. Sorry.
What if I need to run a script as an administrator? What arguments do I need to pass?
@ShanesCows
6 жыл бұрын
I am pretty sure you can tell the timer job to run as admin? This post has a lot of ideas but I haven’t tried any. Sorry. superuser.com/questions/108207/how-to-run-a-powershell-script-as-administrator
thanks
@ShanesCows
Жыл бұрын
You're welcome!
Great video Shane!But how can we run the powershell script every 15 or 10 minutes automatically?
@ShanesCows
4 жыл бұрын
Change the schedule.
Any thoughts on how to run powershell script as a service?
@ShanesCows
4 жыл бұрын
I haven’t done that. Sorry
Stumbled upon your videos recently.Liked it and am following very much.I have a doubt though. I am unable to save my scripts. My "Save as" is greyed out.can you please help?.thanks in advance Shane.
@shivas3381
4 жыл бұрын
Never mind ,Got it...I saved .txt as .ps1 and opened it in ISE
@ShanesCows
4 жыл бұрын
awesome
Can we change name of folder or file by using PS code
@ShanesCows
5 жыл бұрын
Yes. There is a rename.
Hi Shane, Can you please make a video on - How to start multiple bat files sequentially from PowerShell script
@ShanesCows
5 жыл бұрын
I haven don’t that before. Sorry
And does it matter whether the client is turned on or not?
@ShanesCows
Жыл бұрын
Client has to be on.
So what if you PowerShell is looking for input. Select A for all?
@ShanesCows
3 жыл бұрын
I think so but not exactly sure where you are seeing that.
@donnielewis186
3 жыл бұрын
@@ShanesCows Thanks. What I'm asking is I have a powershell that will kick off disconnected users. It ask me what server and what group of users I want to kick off... I cant figure out how to input those values so that i can run in nightly to disconnect the usrs that "forgot" to log off. I had found that someone said to add the argument -command “& ‘c:\PSFiles\LogOffSession.ps1’ ‘ServerName’ ‘Disc'”... Not working though.
how can i schedule my Powershell script in my base machine to run on Azure portal.
@ShanesCows
6 жыл бұрын
Hi Darshan - I don't exactly understand your question? Can you give me more details? Thanks
@darshanhc7424
6 жыл бұрын
HI Shane, I want to run some Powershell script which uploads some file to azure ADLS and get some more information from Azure portal. But i want the script to run from my base machine powershell prompt. everytime i Dont want to login to azure portal via powershell and execute the script. (I can create profile in powershell and through that i can run my main script. But other than powershell profile concept how can i do this.) instead if i schedule the script how do i do that.? and one more question...., In azure portal for VM monitoring i can create metric alerts. but how to create metric alert to monitor RAM usage and disk usages like C, D, and E drives. i can select metric for %CPU usage, but for RAM and disk usage what parameters should i select. Please help me on this. Will be waiting for your response. Thank you.
I have a question: I created a Task Scheduler that runs a batch file. The batch file kills a process and then uses a "start " command to launch the same application (.EXE). The batch file runs flawlessly if I manually double-click it to make it run. However, when Task Manager runs the batch file, it kills the process but does not start the application.Also, the task is listed as "Running" for about a minute before it comes "Ready" again. Have you seen this before? I am running WIN7. Thanks in advance!
@ShanesCows
5 жыл бұрын
Sorry. I have not messed with that before. 😑
How about a powershell script that could be used to send emails when a specific event triggers in system?
@ShanesCows
5 жыл бұрын
Should be possible. There is a cmdlet for sending email.
Nice video. Just wanted to know how to take the current config back up
how to schedule by month ?
@ShanesCows
3 жыл бұрын
Not sure, I haven't done that.
How about a PowerShell script to create a schedule task, that runs a PowerShell script? That's the real goal. ;)
@ShanesCows
6 жыл бұрын
I will have to look at it but I think that is pretty doable.
@funhurtsmylungs1056
6 жыл бұрын
Oh yeah it is. Just thought its funny :)
@ShanesCows
6 жыл бұрын
LOL. Yeah, my literal hat was on. I see what you did there. Though I do think this is a solid video idea also.
@funhurtsmylungs1056
6 жыл бұрын
Shane Young I’ve got a script that I think your viewers might be interested in. What’s the best way to contact you about it?
@ShanesCows
6 жыл бұрын
shane.young at boldzebras.com I can't wait to see it. Thanks
Any chance you could possibly demonstrate using powershell to run a sql select statement then send those results via ftp on a csv file? Is that possible to do? Been playing with the syntax but I'm not able to figure it out.
@ShanesCows
4 жыл бұрын
Yikes. I haven't done that one. Sorry.
@xeonzero1
4 жыл бұрын
@@ShanesCows no problem. I'll keep digging. Thanks for the quick reply!
Hi Shane, Thanks for this video. I want to check daily if a file exists and then send automated mail if file is not created in a folder on a particular day. How can I do this using powershell and task scheduler? Can we send automated email (no manual intervention) using powershell? Please guide.
@ShanesCows
4 жыл бұрын
I am not sure. Sorry. I use Microsoft Flow for things like that these days.
my windows say 'value does not fall within the expected range'
@ShanesCows
3 жыл бұрын
Not sure why. Sorry
How to run a PS script daily as a service account, please? And it should not have any human intervention.
is there a way to tell it to start a certain line on the script after logon so you don't rerun what's already completed?
@ShanesCows
2 жыл бұрын
Not that I have done but maybe. I guess you could have if Logic to have it skips sections?
Hey Shane Please could you do a video that creates a task scheduler with a bash script
Hi shane! This video is really useful.I want to set a task scheduler using powershell script. It has to trigger weekly once. It has to give prompt to users reboot the device. Could you please help me with this how to write a script for this.
5:52 i'm currently using vbscripts and all i have to do is press the "browse" button and browse to the location of my vbscript file. this seems more complicated, however i heard vbscripts can be a security issue
@ShanesCows
3 жыл бұрын
I would just say this is a different option.😀
Greetings Sir, Off the topic question, but still out of curiosity. Is there any way to export driver using power shell on Windows 7 system? I tried the dism /Online /Export-Driver /Destination:C:\Drivers command but it doesn't work (Error: 87). Regards.
@ShanesCows
4 жыл бұрын
I don’t know. Sorry
How do we add the hostname on the text file using the Powershell
Easy and nice. How can we automate email report.
How about a script to prompt user for varible like ##$Store =read-host -prompt "Store Location?"## ping multiple hosts ## ping "$Store"rtf -t. Ping "$Store"sw -t## outputting results to two frames then turning frame red upon a failed ping, wait for user input to stop pings, and then loop itself
@ShanesCows
5 жыл бұрын
Yikes. Not sure on that one.
So I have this strange problem with running a Powershell script with a scheduled task. The task will trigger on a 1074 event ID (event ID for shutdown or reboot). If I shutdown the task will run and execute the script. If I reboot the task will run, but after reboot the comment says the task was started but was interrupted by the user. It gives error code 2147943515. Someone any ideas?
Maybe better to get to the point quicker. You were half-way through before you got to the subject of automating the script.
@ShanesCows
5 жыл бұрын
Sorry you didn’t like it. 😔
Start at 4:55 lol
@ShanesCows
3 жыл бұрын
😎
So here is my requirement First please help me with the script to launch Visual Studio Test from powershell using windows scheduler Second, I want to intentionally stop that test case close the desktop app on which I am performing automation and invoke it again This should happen in every half an hour So it should keep doing this process like an infinite loop