![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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) | ||||||||||||
| Guest | 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
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | 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:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | 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:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: Pinging In message <8BE81327-92DE-4F6C-8D35-007BF66A3ED7@xxxxxx>, PShellNoober <PShellNoober@xxxxxx> writes
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) | ||||||||||||||||||||||||
| Guest | 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:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #7 (permalink) | ||||||||||||||||||||||||
| Guest | 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
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #8 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | 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
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #9 (permalink) | ||||||||||||||||||||||||||||||||||||||||||||||||
| Guest | Re: Pinging In message <99713A8E-8CB1-4625-B56C-72399A18801D@xxxxxx>, PShellNoober <PShellNoober@xxxxxx> writes
ping.csv. :-(
Thomas Lee doctordns@xxxxxx MVP - Admin Frameworks and Security | ||||||||||||||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||||||||||||||
| | #10 (permalink) | ||||||||||||
| Guest | 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
| ||||||||||||
My System Specs![]() | |||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Switch the Pinging from IPv6 to Ping IPv4 | VistaKing | Network & Internet | 2 | 5 Days Ago 02:15 AM |
| Problem pinging computer on a domain using Vista Business | Flip Lewis | Vista security | 0 | 05-12-2008 10:49 AM |
| Pinging one server within the same subnet fails but works in anoth | Matt Wilson | Vista networking & sharing | 9 | 06-01-2007 10:38 AM |
| General failure when pinging local nic after Basic to Premium Upgr | Jeff | Vista General | 6 | 05-13-2007 06:29 PM |
| Pinging Justin: OT on SRT8 Chargers | HEMI-Powered | Vista General | 4 | 03-17-2007 06:50 AM |