June 21, 2020 at 4:11 am #237175ParticipantTopics: 1Replies: 1Points: 18Rank: Member
I have a powershell api script that changing wifi passwords in Meraki.
Now i want to add this script to Task Scheduler and execute it with a specific command line, for example:
In “Action” section i’m always putting those lines:
Program/script : Powershell.exe
Add arguments : -ExecutionPolicy Bypass C:\Policies\Meraki\ChangePass.ps1
But this won’t work here, because this script can be executed only when using this command:
.\ChangePass.ps1 -site "Building1" -ssid "Wifi-Guest" -action "Change"
Thanks for help
June 21, 2020 at 6:24 am #237187ParticipantTopics: 5Replies: 2384Points: 6,066Rank: Community MVP
al, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.
When you post code, error messages, sample data or console output format it as code, please.
In the “Text” view you can use the code tags “PRE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
Thanks in advance.
To circumvent such problems I’d recommend using config or settings files instead of command line parameters. Then you even do not need to change the scheduled task if you want to change the behaviour of the script. 😉
June 21, 2020 at 6:29 am #237193ParticipantTopics: 1Replies: 1Points: 18Rank: Member
Thanks, i edited the post.
And i didn’t understand the solution that you provided, can you explain a little bit more about it?
June 21, 2020 at 7:12 am #237196ParticipantTopics: 5Replies: 2384Points: 6,066Rank: Community MVP
Instead of providing command line parameters to control the behaviour of a script you save the needed setting in a text file next to the script file and in your script you read this settings file to get the contained settings. To make it easy to handle and easy to set up you should use a standardized format like JSON or a powershell data file. I like to use the latter one because it’s easy to write and easy to use.
- You must be logged in to reply to this topic.