- OS: Windows Server 2016, AD domain joined.
- Software: Intel Fortran Compiler run from the command prompt (no expertise required)
- Active Directory, Powershell scripting, ScheduledTasks, Windows Task Scheduler, Powershell remote sessions
Desired User Operation:
1. Multiple domain users will connect to the server using a Powershell remote session and their domain credentials.
2. The script will need to use the user’s current working directory as a variable.
If this is not possible, then the current working directory will somehow need to be passed to the script as a variable. Either one of the following methods is acceptable:
a) From the prompt, user changes path to the drive and folder where the control file exists and an output file will be generated. Automatically determine the current drive/folder path and pass it as a parameter to the script. This is preferred.
b) Alternatively, have the user pass the drive and folder path as a parameter (eg. X:\Projects\RunFolderName)
3. User will enter command (the new script) with several parameters. For example (Note: the number 4 refers to an optional numeric parameter):
NewScriptName [login to view URL] [login to view URL] 4
Current state of project:
I’ve created a scheduled task, which works if I manually execute it. The problem is that the parameters are hard-coded. Here is the task’s configuration:
- General Tab:
o Location is a sub-folder (TestSched).
o When running the task, use the following user account: (a domain user account is specified)
o Run whether user is logged on or not is selected
o Run with highest privileges is selected (may not be needed)
- Triggers Tab:
o Trigger: “When the task is created or modified”
o Action: Start a program
o Program/script: C:\Windows\System32\[login to view URL]
o Add arguments: /E:ON /V:ON /K “C:\user\username\[login to view URL] (see [login to view URL] contents below)
o If the task is already running, then the following rule applies: Queue a new instance
Contents of [login to view URL] (will be needed to flesh out the new script):
REM batch file needed to set up the compiler environment, which must be preserved forward:
call "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.1.156\windows\bin\[login to view URL]" intel64 vs2015
REM change directory to the location of the control file and output file (Note: need to either automatically use the user’s current directory, or have the user enter the working drive/folder path as a parameter):
cd /d P:\Projects\Client\ABCcorp\runfolder
REM execute my compiler software with the parameters passed from the user (Note: the number 4 is an optional, numeric parameter):
C:\mysoftware\mycompiler [login to view URL] [login to view URL] 4
Mechanism must be robust enough so that several users can stack multiple scheduled tasks into the queue.
A powershell script (preferable) or batch file needs to be written that can pass parameters to, and run a set of commands in, a Windows scheduled task. Greatly prefer to use ScheduledTasks (not the older Schtasks).
[login to view URL]
The script will:
- accept parameters from the user
- create a new task or update an existing task (eg. New-ScheduledTask or SetScheduledTask). Use a separate task for each user, if necessary
- trigger the task to run immediately, or queue the task if already running
- When task is created in task scheduler, it asks for credentials, user can be prompted for their domain user/password if needed.
- If user password is passed as a parameter, use SecureString to avoid exposing sensitive info.
- If helpful, I’m willing to set up a predefined task, or a task for each user, that can be controlled by the script.
Hello, I can help with you in your project Powershell scripting and Task Scheduler Wizardry document. I have more than 5 years of experience in Microsoft, Powershell, Shell Script, Software Architecture, Windows Ser Daha Fazla