I'm creating a window task using powershell, everthing is ok, but i can't find how to add the Author name. Register-ScheduledTask as a parameter for description but not for Author.
Exported Windows task
<RegistrationInfo>
<Date>2016-05-17T16:45:54.3423362</Date>
<Author>NEED TO SET THIS</Author>
<URI>RunLauncherTask</URI>
</RegistrationInfo>
Code that a i use for create the task
$principal = New-ScheduledTaskPrincipal -UserId (Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -expand UserName)
$allTasks = Get-ScheduledTask | Select TaskName
$action = New-ScheduledTaskAction -Execute "C:\Launcher.exe"
$trigger = New-ScheduledTaskTrigger -AtLogOn
$task = New-ScheduledTask -Action $action -Trigger $trigger -Principal $principal
$username = $principal.UserId
$taskName = 'RunLauncherTask' + $username.Replace('\','-')
$settings = New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries
Register-ScheduledTask $taskName -Action $action -Settings $settings
How do i set the autor?
Unfortunately, the only way to do this is via the -xml
option.
Do note that the option takes the actual string, not a file name.
$xml = @"
....
....
"@
Register-ScheduledTask -Xml $xml -TaskName $task_name