please help with my first script

This is my first attempt at a real script, I have made really basic .bat files but this is my first delve into powershell.

bit of background on the script. I needed a tool that I can run when a customer loses connection to the internet, and rather than just run ping -t X.X.X.X and manually check it every 20 minutes, I wanted something that

a) pinged once a minute

b)notified me as soon as a succesful ping was made

c)needs to be able to be used by other members of the service desk who have little to no scripting knowledge.

Now what I have created works for me and I can manipulate the $IP to my needs, but I would like it to prompt the user to enter the IP address.

When I tried to get this to work, it did not wait for the prompt but just went straight to the next line in the script and accepted that as the value for $IP.

Feedback, critique or any source material would be greatfully appreciated.

Script below:

$IP = ‘’

$online = $false

do {

If (Test-Connection $IP -Count 1 -Quiet) { $online = $true } Else { Start-Sleep -Seconds 60 } 

} Until ($online) {$true}

$popup1 = new-object -comobject

$popupsuccess = $popup1.popup(“They are back online“,0,“Success!”,1)

If ($online = $true ) {$popupsuccess}

Clear-variable -Name “IP”

Clear-variable -Name “popup1”

Clear-variable -Name “popupsuccess”

Clear-variable -Name “online”

thanks in advance

submitted by /u/CallMeCurious
[link] [comments]

Leave a Reply