Using psake for Server deployment. How would you go about restarting the computer and resuming the script?

263 views
Skip to first unread message

Caleb Jares

unread,
Jun 29, 2012, 2:35:05 PM6/29/12
to psake...@googlegroups.com
I was thinking something like

# reboot the server to go here. First add a scheduled task to resume
schtasks.exe /create /SC ONLOGON /TN ScriptResume /TR "powershell.exe powershell arguments go here"
shutdown.exe /R /T 0
# resume here. First remove the task
shctasks.exe /delete /TN ScriptResume

Is this something worth adding as a feature?

Damian Hickey

unread,
Jun 30, 2012, 3:41:02 PM6/30/12
to psake...@googlegroups.com
psake is a msbuild / nant replacement. While powershell based I don't think deployment is what it is intended for.

--
You received this message because you are subscribed to the Google Groups "psake-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/psake-users/-/DrZTG4LgWowJ.
To post to this group, send email to psake...@googlegroups.com.
To unsubscribe from this group, send email to psake-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/psake-users?hl=en.

j.barrett strausser

unread,
Jun 30, 2012, 3:57:33 PM6/30/12
to psake...@googlegroups.com
Part of that is almost msbuild's fault. Msbuild supports all sort of operations like service starting, app pool recycling etc.
Anything beyond compilation and weddeploy package creation I think should fall to power-shell.

matt wrock

unread,
Jul 3, 2012, 12:59:58 AM7/3/12
to psake...@googlegroups.com
I'm not sure this would be something that fits under the core psake module. Its strength is really providing a build harness environment with a nice dependency graphing moel. However, I have used psake for not only routine builds but also for deployments and bootstraping environment setups. I have ran into a couple scenarios where I needed to perform a restart and continue the setup psake build afterwards.For example, I have a task that downloads and installs critical windows updates. Here is an example of the task:

Task Check-And-Install-Updates -description "Checks for critical updates and installs them. Will Reboot if necessary."{
    if( Test-Path "$env:appdata\Microsoft\Windows\Start Menu\Programs\Startup\bootstrap-post-restart.bat") {
        remove-item "$env:appdata\Microsoft\Windows\Start Menu\Programs\Startup\bootstrap-post-restart.bat"
    }
    Write-Output "Downloading and installing any critical updates. Will reboot if necessary..."
    & \\tkfiltoolbox\tools\23649\3.0.37.2319\critfix.exe /restart none
    if($lastexitcode -eq 3010) { #Restart needed
        New-Item "$env:appdata\Microsoft\Windows\Start Menu\Programs\Startup\bootstrap-post-restart.bat" -type file -force -value "c:\bootstrap\psake\psake.ps1 $tasklist -Properties @{TemplateWorkspace=$TemplateWorkspace;SourcePath=$SourcePath;BinariesPath=$BinariesPath;SqlInstanceName=$SqlInstanceName;Log=$Log;zone=$zone}"
        Write-Output "Restart Required. Restarting now..."
        Restart-Computer -force
    }
}

If I need to restart, I create a batch file in the windows startup directory that will call psake with the same params it was called with. Almost all of my tasks have PreCondition params that check to see if the task needs to run and avoids duplicate task execution so the need to resume from where I left is mitigated by that.
Reply all
Reply to author
Forward
0 new messages