I'm creating a Scheduled task from SCCM as follows
$Action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "-NonInteractive -NoLogo -NoProfile -File '$env:windir\UserCustomisations.ps1'"
$Trigger = New-ScheduledTaskTrigger -AtLogOn
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName 'CBC User Customisations' -Description 'Created by SCCM Build. Runs at logon under users own credential to run user specific customisations'
This is fine BUT I want it to run under user context at logon time. I found an article about changing (manually) the run as to the "users" group and that appears to work, but what I can't do is to get that name into the Powershell cmd. I've tried saying -user 'Users' and 'Builtin\Users' but PS just throw up an error – I assume because its looking for a user rather than a group. Any thoughts ??