Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

How to continue script after server reboots?

$
0
0

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

 

 


Viewing all articles
Browse latest Browse all 8411