Now i have spent much to time to solve this, hope someone of you guys have a solution for me. What is then i want to achieve?
I have computers that are not accessable through powershell remoteing or another remote. So my last hope is that i can
do it through invoke-vmscript. I do many other things through invoke-vmscript so i know it is working.
I have a schedule task that runs as system with highest privileges and runs whether a user is logged on or not.
This task i am trying to start through invoke-vmscript
The script look like this, i have the script at work so some characters can be wrong, but you can see sort of what i am trying to do
The error is like this "This operation requires an interactive window station"
My shedule task is a powershell script that is on netlogon share.
-------------------------------------------------------------------------------------------------------
$scripttext = '
schtasks /run /tn ThisIsMyScheduleTaskName
'
invoke-vmscript -vm $vm -scripttext $scripttext -guestcredential $Cred
-------------------------------------------------------------------------------------------------------
What i can understand is the you must start schedule job as admin. If i on the remote computer start cmd and run schtasks,i
got access denied. But if i start cmd as admin and then run schtasks, it works.
I can run this on the remote computer: Start-Process -FilePath cmd.exe -verb runas
Now cmd is starting as admin and i can start my job
I have also tried with start-scheduledtask in scripttext block but same error.
I have also tried to disable UAC, and this have nothing to do with a schedule task
i have domain admins to use, so i think i can do the most of things.
Did you try creating the scheduled task with PS (like I showed inRe: scheduling_powershell script_task scheduler )?
You can run that on the remote station through Invoke-VMScript.
The user/password can be changed on the Register-ScheduledTask cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i have not tested that, i have a gpo that create the schedule task during startup but that is not really neccesarry.
I will try you solution, thanks