![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Pinging I was wondering if there is a way to set a time to ping a certain server. I'm using the line Get-WmiObject -Class Win32_PingStatus -Filter "myserver" | Select-Object -Property Address, ResponseTime to ping the server once. So is there a way to run this lets say every 10 minutes? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Pinging Sure you can. Save your commands into a ps1 file. Configure new Scheduled task. In the "Run" textbox type: C:\WINDOWS\system32\WINDOW~1\v1.0\powershell.exe <path to your script.ps1> On the schedule tab choose to run it "Daily", click advanced, tick the repeat task checkbox, choose 10 minutes, tick "duration" and type 24 for "hours" and 0 for "minutes" ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I was wondering if there is a way to set a time to ping a certain > server. > > I'm using the line > > Get-WmiObject -Class Win32_PingStatus -Filter "myserver" | > Select-Object -Property Address, ResponseTime > > to ping the server once. > > So is there a way to run this lets say every 10 minutes? > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Pinging if you want the window open and just running forever until you press ctrl+C have a loop then after you ping do a start sleep start-sleep 600 PShellNoober wrote: Quote: > I was wondering if there is a way to set a time to ping a certain server. > > I'm using the line > > Get-WmiObject -Class Win32_PingStatus -Filter "myserver" | Select-Object > -Property Address, ResponseTime > > to ping the server once. > > So is there a way to run this lets say every 10 minutes? |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Pinging Awesome, Thank You. One more question: If I have a list of servers, can I import that list into the string so it will ping all the servers in the list? I tried something like this, and it just prints out the 2 servers I have listed in the .csv $DC = get-content "C:\test\dc.csv" Get-WmiObject -Class Win32_PingStatus -Filter "Address='$DC'" | ` Select-Object -Property Address,ResponseTime | export-csv c:\test\ping.csv I know the import works if I only have one server listed in the file, so I must be missing something. Thanks for any help "Shay Levi" wrote: Quote: > Sure you can. Save your commands into a ps1 file. > Configure new Scheduled task. In the "Run" textbox type: > > C:\WINDOWS\system32\WINDOW~1\v1.0\powershell.exe <path to your script.ps1> > > On the schedule tab choose to run it "Daily", click advanced, tick the repeat > task checkbox, choose 10 minutes, > tick "duration" and type 24 for "hours" and 0 for "minutes" > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > > Quote: > > I was wondering if there is a way to set a time to ping a certain > > server. > > > > I'm using the line > > > > Get-WmiObject -Class Win32_PingStatus -Filter "myserver" | > > Select-Object -Property Address, ResponseTime > > > > to ping the server once. > > > > So is there a way to run this lets say every 10 minutes? > > > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Pinging In message <8BE81327-92DE-4F6C-8D35-007BF66A3ED7@xxxxxx>, PShellNoober <PShellNoober@xxxxxx> writes Quote: >$DC = get-content "C:\test\dc.csv" Get-WmiObject -Class Win32_PingStatus -Filter "Address='$comp'" | ` Select-Object -Property Address,ResponseTime | ` export-csv c:\test\ping.csv } -- Thomas Lee doctordns@xxxxxx MVP - Admin Frameworks and Security |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Pinging The loop kind of works, it only prints out the last server in the list. Any ideas of why it's skipping the first two? "Thomas Lee" wrote: Quote: > In message <8BE81327-92DE-4F6C-8D35-007BF66A3ED7@xxxxxx>, > PShellNoober <PShellNoober@xxxxxx> writes Quote: > >$DC = get-content "C:\test\dc.csv" > foreach ($comp in $dc) { > Get-WmiObject -Class Win32_PingStatus -Filter "Address='$comp'" | ` > Select-Object -Property Address,ResponseTime | ` > export-csv c:\test\ping.csv > } > -- > Thomas Lee > doctordns@xxxxxx > MVP - Admin Frameworks and Security > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Pinging You can also schedule the task with schtasks.exe: schtasks /s <computerName> /create /sc minute /mo 10 /tn "PowerShell Script" /tr "C:\WINDOWS\system32\WINDOW~1\v1.0\powershell.exe c:\scripts\yourScript.ps1" /ru <username> /rp <password> More examples can be found here: http://www.microsoft.com/resources/d....mspx?mfr=true ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Sure you can. Save your commands into a ps1 file. > Configure new Scheduled task. In the "Run" textbox type: > C:\WINDOWS\system32\WINDOW~1\v1.0\powershell.exe <path to your > script.ps1> > > On the schedule tab choose to run it "Daily", click advanced, tick the > repeat > task checkbox, choose 10 minutes, > tick "duration" and type 24 for "hours" and 0 for "minutes" > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com Quote: >> I was wondering if there is a way to set a time to ping a certain >> server. >> >> I'm using the line >> >> Get-WmiObject -Class Win32_PingStatus -Filter "myserver" | >> Select-Object -Property Address, ResponseTime >> >> to ping the server once. >> >> So is there a way to run this lets say every 10 minutes? >> |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Pinging Thomas, Keep in mind that the foreach loop will overwrite the csv file each iteration and eventually only the last remote machine address and response time will be recorded. Add-Content will do the job. foreach ($comp in $dc) { $ping=Get-WmiObject -query "select Address,ResponseTime from Win32_PingStatus where Address='$comp'"; add-content c:\test\ping.csv "$($ping.address),$($ping.ResponseTime)"; } ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > The loop kind of works, it only prints out the last server in the > list. Any ideas of why it's skipping the first two? > > "Thomas Lee" wrote: > Quote: >> In message <8BE81327-92DE-4F6C-8D35-007BF66A3ED7@xxxxxx>, >> PShellNoober <PShellNoober@xxxxxx> writes >> Quote: >>> $DC = get-content "C:\test\dc.csv" >>> >> Get-WmiObject -Class Win32_PingStatus -Filter "Address='$comp'" | ` >> Select-Object -Property Address,ResponseTime | ` >> export-csv c:\test\ping.csv >> } >> -- >> Thomas Lee >> doctordns@xxxxxx >> MVP - Admin Frameworks and Security |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Pinging In message <99713A8E-8CB1-4625-B56C-72399A18801D@xxxxxx>, PShellNoober <PShellNoober@xxxxxx> writes Quote: >The loop kind of works, it only prints out the last server in the list. Any >ideas of why it's skipping the first two? ping.csv. :-( Quote: >"Thomas Lee" wrote: > Quote: >> In message <8BE81327-92DE-4F6C-8D35-007BF66A3ED7@xxxxxx>, >> PShellNoober <PShellNoober@xxxxxx> writes Quote: >> >$DC = get-content "C:\test\dc.csv" >> foreach ($comp in $dc) { >> Get-WmiObject -Class Win32_PingStatus -Filter "Address='$comp'" | ` >> Select-Object -Property Address,ResponseTime | ` >> export-csv c:\test\ping.csv >> } >> -- >> Thomas Lee >> doctordns@xxxxxx >> MVP - Admin Frameworks and Security >> Thomas Lee doctordns@xxxxxx MVP - Admin Frameworks and Security |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Pinging You can also use the .net native ping class, you can ping by ip or host name. Declare $ping outside the loop and call the send method in each iteration. PS > $ping = new-object System.Net.NetworkInformation.Ping; PS > $res=$ping.send("google.com"); PS > $res Status : Success Address : 72.14.207.99 RoundtripTime : 179 Options : System.Net.NetworkInformation.PingOptions Buffer : {97, 98, 99, 100...} ######## $dc = get-content "C:\test\dc.csv" $ping = new-object System.Net.NetworkInformation.Ping; foreach ($comp in $dc) { $res=$ping.send($comp); add-content c:\test\ping.csv "$($res.address),$($res.Status),$($res.RoundtripTime)"; } ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I was wondering if there is a way to set a time to ping a certain > server. > > I'm using the line > > Get-WmiObject -Class Win32_PingStatus -Filter "myserver" | > Select-Object -Property Address, ResponseTime > > to ping the server once. > > So is there a way to run this lets say every 10 minutes? > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Pinging Self Doesn't Work | Network & Sharing | |||
| Now pinging isn't ever right XP to Vista | Vista networking & sharing | |||
| Switch the Pinging from IPv6 to Ping IPv4 | Network & Sharing | |||
| Pinging one server within the same subnet fails but works in anoth | Vista networking & sharing | |||
| Pinging Justin: OT on SRT8 Chargers | Vista General | |||