How to create and schedule a task in windows task scheduler using powershell commands? - powershell

I want to create and run task in windows task scheduler using powershell commands.
I have a script and want to schedule task for this script only by using powershell commands not by gui interface.
Please provide a solution as soon as possible......

I would use schtasks.exe. No need to reinvent the wheel. You can either import from an XML file or create it from the command line.
Just because you're using Powershell doesn't mean everything you're doing must be with a cmdlet or .NET objects. Indeed, many things you'll want to do aren't even exposed in .NET. You'll need to use Win32 or COM objects to get them done.

Related

Azure automation - Graphical PowerShell script run parallel?

Can anyone confirm Graphical PowerShell script run parallel or not? I have PowerShell scripts using power shell scripts I created graphical runbook as below screenshot and when I checked verbose log it seems it run sequential only.
But Asper Microsoft it run parallel.
so Is there any configuration to make it parallel run?
My requirement is out of 3 scripts, two scripts run parallelly and one script run only when first 2 scripts are completed. If we have any alternative solution it also accepted.
The powershell runbooks are based on windows powershell workflows thus we can run the scripts parallel.
This is achieved using the keyword Parallel in the script block and everything under the parallel script block will be run parallel and you can state activities outside the block too since you want one of the activities not to be run parallelly.
Parallel {
<activity 1>
<activity 2>
}
<activity 3 >
Refer the following documentation on powershell workflow
Refer the following documentation on the parallel processing

I need a powershell script to use zmodem for file transfer in microsoft IIS.

I want to use powershell to do file transfer, but I have to use zmodem. Is there a powershell script for this? I know no better way to exchange data using php in a Windows/IIS environment.
use rs232xfer to communicate with modem, skip powershell since it has no pre-made zmodem script

Obtaining the DistributedTaskContext in a custom TFS Build/Release Script

I'm using TFS 2015 Update 2 along with the new Build/Release system. I have a powershell script I'm executing via the Powershell Task. This task executes a powershell script that needs access to the $distributedExecutionContext magic variable I see in many different VSTS Task code samples.
This script in question is not technically a task, but instead is being executed by the Powershell task that comes delivered with TFS.
No matter what I do, I can't see to obtain the $distributedExecutionContext variable. It's always null. Here is an example:
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
if($distributedTaskContext)
{
#... this never happens
}
Is this variable only available if the powershell being run is being run inside an actual task?
The default powershell task that you are using runs the script entirely as a different process and the $distributedTaskContext variable is not available to the script.
It is only available only to the task's powershell script.
If you are going to write a custom task, I would like you to use the new vsts-task-lib SDK which improves a lot over old SDK.

Is it possible to log all powershell commands run on a machine?

We have some .net applications running on a server that run powershell scripts. Is there a setting where we can log every single powershell command run on that machine, without modifying our existing applications? I already tried start-transcript . That command only captures the commands run in the current session.
I believe Microsoft calls what you're after "Over the Shoulder Transcription". It's described here, and will be available in WMF5.

How does Empire Powershell interact with PowerShell?

The creators of Empire PowerShell state the following:
"Empire implements the ability to run PowerShell agents without
needing powershell.exe"
https://github.com/PowerShellEmpire/Empire
Wouldn't running any component of PowerShell require the executable?
From what I've seen of the source, especially the functions starting here in helpers.py it merely wraps the PowerShell executable. There's a lot in there that's sort of haphazard command parsing and construction and output parsing. I would have actually expected it to be a PowerShell host that simply offers a Python API, but from the looks of it, it's a Python API that wraps a few commands, simply shells out to PowerShell, and parses the output as text.