How can I create a windows shutdown script from powershell/command-line?
I've read the TechNet pages that describe using computer/user startup/shutdown scripts, and that's great, but I'd like to create those scripts via the command-line (and not have to click around in gpedit.msc).
It looks like scripts.ini and psscripts.ini in %SYSTEMROOT%\System32\GroupPolicy\Machine\Scripts specifies the scripts to run, but those don't exist until running gpedit.msc for the first time. Is it safe to create and edit those directly? Or do I need to muck around with Set-GPO or something similar? Thanks!
Group Policy assumes you are in an Active Directory domain environment, in which case Group Policy Objects (GPOs) are centrally managed and assigned to computers. For individual machines, the Local Security Policy can be used to produce similar results to centrally managed GPOs.
Typically in Active Directory, login scripts are assigned to User objects, though you can also do this through Group Policy.
If you're not using Active Directory, or you only want to configure this on a relatively small number of computers, you can certainly do this with PowerShell using the Task Scheduler. With Task Scheduler you can create events to run at startup, session end, or logon.