problem starting ise with a pre-loaded script at logon

I am modifying our corporate image using a PowerShell script named InstallScript. I prefer to open that InstallScript with the ISE after I login and watch it execute in order to follow any error messages, etc.

I assume its possible to login to a machine and have the ISE open with a script (,\InstallScript.ps1) already loaded in the script editor.

I thought I could do this with a Scheduled Job that would trigger upon user login;, however, I keep getting hung up. When I log on to a machine, I never see the PowerShell ISE; the TaskScheduler reports the Job ran successfully.

#Prepare the machine for use on the next logon from this person

Get-ScheduledJob | Where-Object { $_.Name -match ‘LogonScript’ } | Unregister-ScheduledJob

[scriptblock]$scriptblock = { "Start-Process PowerShell_ISE.exe -Verb RunAs -ArgumentList ‘C:\Install\InstallScript.ps1’ " }
$SchedJobProps = @{}
$SchedJobProps.ScriptBlock = $scriptblock
$SchedJobProps.Name = ‘LogonScript’
$SchedJobProps.Trigger = ( New-JobTrigger -AtLogOn -User $env:USERNAME )
$SchedJobProps.ScheduledJobOption = ( New-ScheduledJobOption -RequireNetwork -WakeToRun -MultipleInstancePolicy “IgnoreNew” -RunElevated )
$SchedJobProps

Register-ScheduledJob @SchedJobProps

I would recommend you to create a script which logs to a text file, or something similar, instead of what you are doing right now.

Starting the Powershell ISE from a scheduled task and run a script in it interactively doesn’t seem like a good approach at all.

/Alexander

ok. thanks.

I preferred to watch the script’s results during execution. It is fragile enough that I need to make constant adjustments, and the script requires numerous reboots. I was really hoping to spare myself the steps of opening the ISE as administrator and then opening the install script, and then running it.

This is probably a prime candidate to be restructured as a PowerShell workflow.