Can I run a cmdlet in the IF comparison instead of using a variable?

I'm writing a script to run a continuous Test-Connection ping through task scheduler.  This script, upon a non-response, will write to a custom event log I've set up.
Without writing a book, here's an example of what I want to save time and get more ping requests.  Here's the way I have it now:
$ping1 = Test-Connection 1.1.1.1 -count 1
if ($ping1 -eq $null) {
Write-EventLog blah blah blah
Here's how I would rather do it to save that extra second or two from establishing the variable (this obviously doesn't work, otherwise I wouldn't be posting this):
if ("Test-Connection 1.1.1.1 -count 1" -eq $null) {
Write-EventLog blah blah blah
Is this at all possible?  If so, can you share the syntax?
Right now, I have a foreach running 3 different pings and writing to my custom log on error.  I have purposefully configured one to fail and the other two to be successful.  Right now, I'm getting 8 seconds between that one failure.  Ideally,
with just 3 IPs, this should be 3 seconds.

Hi,
Try this:
If (!(Test-Connection hostname -Quiet -Count 1)) { Write-Host 'Host is down' }
EDIT: ! is used in place of -not. You could also do this:
If ((Test-Connection hostname -Quiet -Count 1) -eq $false) { Write-Host 'Host is down' }
Don't retire TechNet! -
(Don't give up yet - 12,420+ strong and growing)

Similar Messages

  • I have a mac osx version 10.6.8 no windows and i am trying to install a program but keep getting can not run in dos mode  ( the disk says on back works on intel mac with parallels or vm fusion) is this program not compatible with my mac?

    i have a mac osx version 10.6.8 no windows installed and i am trying to install a program but keep getting can not run in dos mode  ( the disk says on back works on intel mac with parallels or vm fusion) is this program not compatible with my mac?

    You run Windows in Parallels or Fusion. Then in Windows you install the program.

  • "iTunes can not run because some of the required fields are missing.  Please reinstall iTunes."  What the ****?!

    "iTunes can not run because some of the required fields are missing.  Please reinstall iTunes."  What the ****?  Please help me figure this out.  I already removed quicktime (as another thread suggested).  I can't get in!

    i get same error.
    I have uninstalled and reinstalled more times than i care to count. but still i get
    itunes cannot run because some of its required files are missing.

  • Can i run a printer off the ethernet cable connection without hurting the imac or is the ethernet slot only for internet connection?

    can i run a printer off the ethernet cable connection without hurting the imac or is the ethernet slot only for internet connection?

    Hi, Alan -
    How can I connect to both printer (HP 4050n, via direct connection) and internet (via LAN), as my iMac has only one R45 port?
    You can, but you'll need to expand your cabling a bit.
    You'll need to get an intermediate ethernet hub, switch, or router. That device sits alone, with the Mac, your printer, and your modem/LAN plugged into it.
    If you are already using a router, either separate or in combination with the modem (many modems have a built-in router), then you just need a hub or switch.
    I use an ethernet switch (10/100/1000) to let both my Macs (a 2010 iMac and an elderly G4 DA model) use my HP4000n printer and my modem. The ethernet switch is a passive device, meaning there's no setup nor instructing it required - it's truly plug-and-play. All four items (two Macs, printer, and modem) are plugged into it via ethernet; both Macs have full-time independent access to the printer and the modem.

  • Can we run script logic at the time of preparing reports.

    Helo Everybody!
    I am new to SAP BPC.
    Can we run script logic at the time of preparing reports.
    Thanks & Regards,
    Satish.

    If you mean, "Can we run script logic at the time of preparing reports" is equivalent to entering data into the report and sending it to the database, then yes, you may run logic as Marcel indicates.  Defualt logic is ALWAYS run for ANY and EVERY set of data that is sent via an input template from the field.  You may also run logic when posting a jOURNAL entry as well.  But be careful....if default logic attempts to perform to MANY or COMPLEX calculations, the time it takes to complete the process may not be in expectations with the users plans.  There is a fine design balance required when planning to run logic at the time of input, as opposed to running in a package or at specific times during the day.
    Hope this helps.

  • Can i run two widgets at the same time on the same page?

    Can i run two widgets at the same time on the same page?
    Hi
    I have created and published 4 free ibooks and i would to run two widgets
    - a countdown clock
    - a review test
    at the same time on the page. Can i do that?
    Thanks in advance
    Haris

    thanks for your answer. Yes indeed HTML widgets run only full screen (snif snif). I consider this as a "distinguishing treatment".
    One solution  i read !!!!! was to create through keynote a countdown clock, to export to quicktime move and to imported at iBA predefined widgets. of course this is not the solution i need.
    So, in order to have at the same widget and run together a count down clock and a preview test (20 questions)  i must
    1)"hack" the preview widget and insert a countdown clock
    2) create a preview test using iAD.....
    thanks again
    haris

  • Can I Run 333Mhz ram in a power mac g5 that uses 400mhz?

    Can I Run 333Mhz ram in a power mac g5 that uses 400mhz?

    No; RAM which can't keep up with the computer's bus will be ignored. Faster RAM will work as long as it's able to operate at the speed the bus requires.
    In any case, ensure that the vendor advertises compatibility with your Mac model.
    (75453)

  • Can you run a windows only Photoshop plugin on a Mac using Parallels?

    Can you run a windows only Photoshop plugin on a Mac using Parallels?   In particular a .8BF plugin like PTFilters.8BF  or Super Cubic.

    If you also have a Photoshop version of the Photoshop application, the answer is of course YES.
    Otherwise, the answer is no,
    If you have the CC subscription, then of course you can install a Photoshop Windows version and run your plug-in.  That'll be separate from your Photoshop Mac install..

  • HT4972 My ipad 1 has never been updated and can't run many apps which makes it of not much use, how do I update it ? A simple step by step idiot proof guide would be best ! Can anyone help please ?

    My ipad 1 has never been updated and can't run many apps which makes it of not much use, how do I update it ? A simple step by step idiot proof guide would be best ! Can anyone help please ?

    You can only update the iPad to iOS 5.1.1and you cannot go any higher. If you never updated that high, you can do so by using iTunes on your computer. You will have to connect the iPad to your computer with the cable and launch iTunes
    You can read more here. Make sure that you read the section about using iTunes. The article starts off with using the Settings on the iPad for WiFi updates. That only works with the iPad 2 and higher that is already running iOS 5.
    Update your iPhone, iPad, or iPod touch - Support - Apple

  • Can I safely save files to the external harddrive I am using as/for a Time Machine?

    Can I safely save files to the external harddrive I am using as/for a Time Machine?

    Because ALL Hard Drives fail. They have been since they were invented. It is just a fact of Spinning hard drives.
    No nothing special about how TM writes to the drive.
    Any hard drive can fail at any time. The day you take it out of the box and plug it in to 10+ years later or anytime in between. Kind of like Life. At some point it ends for everyone. Some sooner some much later.
    I've had some work for years, like 7++ running 24/7. Others have died in months to a few years. I've had externals died faster then internal drive and the funny part is an external drive is nothing but the same type drive used Inside a computer, an Internal drive, put into an External case. But most of the time when an external dies it is not the drive itself but the Enclosures Electronic that fail. Removing the physical drive from the enclosure and using a SATA, or IDE, to USB Adapter the drives are usually still good. I've even taken dead externals and removed the drive and put that drive inside a computer case and they work for X number of years. But that doesn't mean that All Drives are like that.

  • In Windows 8, how can I see an image of the psd file instead of the Photoshop icon?

    In Windows 8, how can I see an image of the psd file instead of the Photoshop icon?

    There are a number of third party solutions for this.  I just use Bridge, so can't recommend one in particular.

  • My Imac is ejecting every disk inserted in it, I cannot access the disks, can any body help me troubleshoot the problem. I am using snow leopard.

    My Imac is ejecting every disk inserted in it, I cannot access the disks, can any body help me troubleshoot the problem. I am using snow leopard.

    Try resetting the SMC Intel-based Macs: Resetting the System Management Controller (SMC) - Apple Support
    and PRAM How to Reset NVRAM on your Mac - Apple Support
    If those don't help you can try a cleaning disc or a quick shot of compressed air. Chances are that your drive has failed, join the club it's not all that uncommon. You can either have it replaced or purchase an inexpensive external drive. Don't buy the cute little Apple USB Superdrive, it won't work on macs with internal drives working or not.

  • Can i unplug time capsule from the ethernet cable and still use it??

    can i unplug time capsule from the ethernet cable and still use it??

    I have tried to extend that wireless line but as soon as i remove the LAN cable i have no internet connection anymore. So basically, does the TC get the signal wireless from the router??
    The Time Capsule can wirelessly extend a wireless signal....but only if it is being provided by another Apple AirPort wireless router.
    If the "main" rotuer there is not an Apple AirPort router,  you will need to connect to the network using a wired Ethernet connection.

  • I'm trying to multi-track using an m-audio device, I can record my guitar fine. However, I want to create a new track so I can record an acoustic tambourine over the top. Instead it records the original guitar as well as tambourine? its really annoying

    I'm trying to multi-track using an m-audio device, I can record my guitar fine. However, I want to create a new track so I can record an acoustic tambourine over the top. Instead it records the original guitar as well as the tambourine coming out with a really distorted sound. I've managed to record over the top of a guitar before and add diferent riffs and sounds but I've tried all of the settings but its still not working. Basically I want to record different tracks without it recording my previous guitar riffs as well. Help would really be appreciated.

    Ah that was it, thanks a lot common sense really but thanks for the help

  • Can I run two PIDs from the same vi?

    Hi
    I want to control speed of the rotating shaft and force applied by the pneumatic cylinder using two different PIDs from the same program.
    I managed to get two PIDs to work separatly using PID control loop VI`s supplied with labview 6.1 (I got Kc, I and D right, so there is no overshoot). When I try to run both PIDs within my vi they don`t work. I again tried various gains and managed to get one PID to work but not the other. Then through trial and error I managed to get a second PID to work but I had to change refresh time of the FOR loop from 100msec to 1msec.
    Does anyone have experience with running two PIDs in the same program? Does the timing of the FOR loop influence PID contorller? Does equiring of other data while run
    ning PID has effect on the PID?
    I would really appreciate any comments/help. I am pretty thrustrated at this time
    Thanks"

    The timing of the FOR loop will influence your PID control, which is a fundamental part of PID control. Acquiring data doesn't affect the PID although it could affect the timing of the loops. For instance if you only have one DAQ card you would want to have it all in one loop because you can not have two AI sessions open to the same card.
    For more detailed information on PID I would recommend reading the "PID Control Toolset
    User Manual" which should have been installed to your machine but can also be found at : PID Control Toolset User Manual"
    Regards,
    JR A.
    Application Engineer
    National Instruments

Maybe you are looking for

  • XMLList to External XML File

    Hi All, I'm new to Flex, but I've been impressed with it so far. I was able to create a simple app, where things like navigation trees and table data were populated based on XML stored inside mx:XMLList tags inside the main document. In order to clea

  • Export a only a Movie Clip

    I am building an interactive website as my final project for my Webmastering class and need to know one thing. First I'll give you my setup. I have four Movie Clips in four seperate layers on my main timeline. I want to export one of those Movie Clip

  • Itunes software installation

    When i try to install itunes 10.5 it gives me the following error There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Please let m

  • Installation of SAP BW 3.5 on SAP R3 5.0

    Hi for all!! I have a question to do for an installation of bw 3.5 It is possible with the new version of SAP R3 5.0 to install BW 3.5 on the same ambient (same client)of R3  and connect directly on this, or you need always of two distinguished machi

  • Sections of report not being displayed on some systems

    Post Author: jlutz CA Forum: General Hello... strange issue... We have these Crystal 11 reports deployed that are being called via a VS .NET 2005 application.  The reports display fine on most systems, but on some systems (Dells, a few years old, 512