I have a powershell script on my network share (\server\dir\my.ps1).
if I run this from command prompt (powershell -file "\server\dir\my.ps1") than work as expected.
if I create a basic task in the scheduler with "Run Only When user logged on" than works as expected.
if check the "Run Whether user is logged on or not" then script won't run
in the action tab:Progam/Script --> powershell; Arguments:-file "\server\dir\my.ps1"
- in the task history I see the task run well ...but the script does nothing...
the user is a regular user
If I change the user to administrator than everything work as expected....
Is it possible to run scheduled task with regular user with "run whether user is logged on or not"?
#So i made some test:
In the PS file i put this script:
Test-Connection -ComputerName SBS | out-file "c:\script\test.txt" $olSession = (New-Object -ComObject Outlook.Application).Session $olSession.Logon('Outlook') $contactsFolder = 10 $elemek = $olSession.GetDefaultFolder($contactsFolder).Items @($elemek)|ForEach-Object {$_.Delete()}
- The first line run as expected (with user logged on or not )
- The rest of line did not run
- If i paste this lines to cmd than everything run as expected
- If i change the settings to "Run only if user logged in" than every line run as expected
- If i give admin rights to user the everything run as expected in logged off too...
So something with my outlook session lines...i don't understand...