Running a powershell script at startup

1

I am writing a script to remove a computer from the domain, rename it, then add it back. It works fine when I set the trigger to AtLogOn but when I switch to AtStartUp I run into some issues. I get this error when it restarts to run the first scheduled task: 0x8007051F: There are currently no logon servers available to service the logon request. I suspect the script tries to run with no network connection set up so I tested using the RandomDelay parameter, and it worked like its suppose to.

I cant rely on a random delay so I am looking for an alternative. Is there a way to test the network status before the script begins or a way to delay the script a specific amount of time? I am using Register-ScheduledJob provided by Powershell 3.0

Thanks in advance

scheduled-tasks
powershell-3.0
asked on Super User Jul 1, 2013 by RandellK02

2 Answers

1

You can probably use Test-Connection cmdlet to ping a domain controller. Loop until a positive response is received.

answered on Super User Jul 1, 2013 by Keltari
-1

Start-Sleep with a if Test-connection = $true against DC

answered on Super User Nov 3, 2014 by Donrsh

User contributions licensed under CC BY-SA 3.0