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

RandellK02

Posted 2013-07-01T03:31:28.933

Reputation: 11

Answers

1

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

Keltari

Posted 2013-07-01T03:31:28.933

Reputation: 57 019

-1

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

Donrsh

Posted 2013-07-01T03:31:28.933

Reputation: 1