How to continue script after server reboots?

by Jun 30, 2014

I would like to do something like this. Code below does not work.

 Set-ExecutionPolicy Unrestricted

workflow New-CustomWorkflow
{
    function DoSomething()
    {
        #Do something that requires restart,
    }

    try
    {
        #Restart-Computer -Wait
        DoSomething
        Restart-Computer -Wait
        Write-Output -InputObject "I NEED TO SEE THIS MESSAGE AND DO OTHER PS1 STUFF."
        DoSomething
        Restart-Computer -Wait
        Write-Output -InputObject "I NEED TO SEE THIS MESSAGE AND DO OTHER PS1 STUFF."
        DoSomething
        Write-Output -InputObject "I NEED TO SEE THIS MESSAGE AND DO OTHER PS1 STUFF."
    }
    catch
    {
        # Do something.
       
    }
}

New-CustomWorkflow