• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 688
  • Last Modified:

MS Server 2003 powershell script at system startup?

I have configured the following ps1 and it works fine.  How can I make this run at system startup, administrator logoff, etc...

$ping=New-Object System.Net.NetworkInformation.Ping;
$remoteIP = "10.151.135.255"
$remoteIP = "10.216.0.229"
$remoteIP = "10.151.132.188"
$remoteIP = "10.151.142.77"
$conn = "Wyless VPN1"
$login = "Telsc2"
$pass = "xxxx"
$a = 1
while ($a = 1) {
  $vpn=$ping.Send($remoteIP)
  if($vpn.Status -eq "Success") {
    Write-Host "VPN OK"
    Start-Sleep -Second 10
  }
  else {
    rasdial $conn /d
    Start-Sleep -Second 2
    rasdial $conn $login $pass
  }
}
0
dhuff2012
Asked:
dhuff2012
2 Solutions
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Create System Startup / Shutdown and User Logon / Logoff Scripts
http://technet.microsoft.com/en-us/magazine/dd630947.aspx

Specify a Script to Run on Startup Shutdown Logon Logoff
http://techsupt.winbatch.com/ts/T000001048F90.html

Overview of Logon, Logoff, Startup, and Shutdown Scripts
http://support.microsoft.com/kb/198642

- Rancy
0
 
als315Commented:
@dhuff2012: you can't set different IP address for one variable. In your example:
$remoteIP = "10.151.135.255"
$remoteIP = "10.216.0.229"
$remoteIP = "10.151.132.188"
$remoteIP = "10.151.142.77"
only last IP (10.151.142.77) will be pinged.
As I've commented in your previous question, you can use scheduler for script starting during startup.
0
 
dhuff2012Author Commented:
Got it fixed.  Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now