I have a dilemma. I am using the Windows Server 2012 scheduler to execute powershell scripts.
To experiment, poured a new W2012, has created a new domain test.wan isolated network .
- Created by user adm, appointed him as the domain administrator.
- Create a directory c:\temp
- Created script d:\backup\test.ps1 with content:
get-date >> c:\temp\log.txt
Set-ExecutionPolicy RemoteSigned unRegister-ScheduledJob -Name Backup
$t = New-JobTrigger -Weekly -DaysOfWeek 1,2,3,4,5 -At 11:00PM
$cred = Get-Credential test\adm
$o = New-ScheduledJobOption -RunElevated
Register-ScheduledJob -Name Backup -FilePath d:\backup\test.ps1 -Trigger $t -Credential $cred -ScheduledJobOption $o
- Start the scheduler and manually run the task - write to the file worked.
- Then i logout test\adm
- Logged under test\Administrator
- Start the scheduler and manually run the task - write to a file does not work in the job log all ok .
- Launched cmd as test\adm
- Start the scheduler and manually run the task - write to the file worked.
Why ? ?
ps: On Windows Server 2008R2 is no such problem.