How can I turn this output into a variable

I have a script to query all the servers in AD
Import-Module active*
$rtn = $null
Get-ADComputer -Filter {operatingsystem -like "*server*"} |
ForEach-Object {
$rtn = Test-Connection -CN $_.dnshostname -Count 1 -BufferSize 16 -Quiet
IF($rtn -match 'True') {write-host -ForegroundColor green $_.dnshostname}
I want to make the output a variable
Easy way would be:
$Servers = Get-ADComputer -Filter {operatingsystem -like "*server*"}
Problem is this would waist time waiting for queries against disabled/powered off machines to error out
I don't know how to use if statements in variables

Hi,
You can do something like this:
$aliveServers = @()
Get-ADComputer -Filter "OperatingSystem -like '*Server*'" | ForEach {
If (Test-Connection -ComputerName $_.Name -Count 1 -Quiet) {
$aliveServers += $_
$aliveServers | Sort Name
Don't retire TechNet! -
(Don't give up yet - 12,950+ strong and growing)

Similar Messages

  • In Yosemite, I can;t operate for more than a few minutes with Keychain or Safari asking for my login password.  How can I turn this off, and still be safe?

    Using Yosemite, I an't seem to work for more than a few minutes without being asked for my login password.  Keychain wants it, Safari wants it, iCloud wants it..the list goes on.  Then in 10 minutes or so, they all want it again.  Passwords are being stored by Safari as usual, but new tabs or pages bring up the request.  How can I turn this off and still have protection?

    Tutorial: Resolving Keychain Issues
    If you can't access your keychain, or forget your password If you can't get into your keychain file because you've forgotten your password or the keychain file appears to be corrupt, there are a couple of options.
    First, if you've forgotten your password, you can use the "Keychain First Aid" utility to make the keychain password the same as the login password. This can be accomplished via the following process:
      1. Open Keychain Access (located in Applications/Utilities)
      2. Go to the "Keychain Access" menu and select "Preferences"
      3. Click the "First Aid" tab
      4. Make sure the "Synchronize login keychain password" box is checked
      5. Close the Preferences window
      6. Go to the "Keychain Access" menu and select "Keychain First Aid"
      7. Enter your username and password
      8. Click the "Repair" button
    The second option is to completely delete your keychain then recreate it. This routine is useful if your keychain appears to be corrupt or otherwise inaccessible. This can be accomplished as follows:
      1. Launch Keychain Access (located in Applications/Utilities)
      2. Click "Show Keychains" in the lower-left corner of the window.
      3. Select the problematic keychain from the left-hand pane.
      4. Navigate to the "File" menu and select "Delete Keychain '(name of keychain)'"
      5. Check all options for deletion and press "OK"
      6. Create a new keychain by going to the "File" menu, then "New" and selecting
          "New Keychain"
      7. You can now make this keychain your default if you desire by selecting it, then
          going to the "File" menu and selecting "Make '(name of keychain)' Default"
    Login as root and perform repair In some cases, problems with keychains can only be resolved when logged in as the root user.
    First, you want to enable the root user:
      1. OS X Mountain Lion: Enable and disable the root user
      2. OS X Lion: Enable and disable the root user
      3. Mac OS X 10.6: Enabling the root user
      4. Enabling and using the "root" user in Mac OS X
    After enabling the root user, and logging in under this account, again open Keychain Access. First attempt repairs using Keychain First Aid, and failing that, delete then recreate the keychain as described above while logged in as root.
    Persistently asked for stored passwords If you are persistently asked for passwords in various applications that you have specified should be remembered in a keychain, your "login" keychain may not be active for one reason or another.
    Navigate to ~/Library/Keychains/ (this is the Library folder inside your user's home folder). Find the file named "login.keychain" and double-click it.
    Failing that, select the "login" keychain within the Keychain Access application and make sure it is the default keychain by going to the "File" menu and selecting "Make 'Login' Default"
    Turn off Keychain synchronization in applications having problems If specific applications are experiencing issues when accessing password-protected material, the Keychain may be to blame.
    The above comes from an article published on MacFixit.com.

  • When i ask a question on ebay and send, when i try to back tab it keeps insisting on resend how can i turn this off?

    you search items on ebay,ask a question of the seller and send it, i then want to return to my listing and the searched items, but firefox will only let me do this if i resend my question every time, it means all the messages i send asking a question are duplicated, how can i turn this annoying protocol off?

    Feedback? Did any of this help?

  • I am English but I live in Spain. when I try to download an app now, as well as my password i get asked to complete a security question from a list. The problem is the list is in Spanish. How can I turn this additional security off

    I am English but I live in Spain. when I try to download an app now, as well as my password i get asked to complete a security question from a list. The problem is the list is in Spanish. How can I turn this additional security off.
    Please note: I dont speak Spanish.
    Please HELP

    You can't turn it off.

  • I want to type "0800" or "20.00"; Pages automatically "corrects" the entries to: "800" and "20." !  How can I turn this automatic correcting OFF?

    In my business it is critical that I be able to enter numbers in the format I choose.  I want to type "0800" or "20.00"; Pages automatically "corrects" the entries to: "800" and "20." !  How can I turn this automatic correcting OFF?  I am a relatively new user of Pages and cannot find a means of turning the autocorrect OFF.or of setting the number formatting rules.

    Pages v5.5.2 does not change 0800, or 20.00 when entered as body text for me. There is nothing in substitution, or Pages preferences settings that can effect these values.
    However, when typed in a Pages table cell with the wrong data format, mischief does occur. In order to preserve 0800, select the Cell tab on the format panel, and set the cell data format to Text, or a custom data format. To preserve 20.00, you must set that cell data format to either Automatic with 2 decimals, or Number with 2 decimals.

  • How can i rewrite this code into java?

    How can i rewrite this code into a java that has a return value?
    this code is written in vb6
    Private Function IsOdd(pintNumberIn) As Boolean
        If (pintNumberIn Mod 2) = 0 Then
            IsOdd = False
        Else
            IsOdd = True
        End If
    End Function   
    Private Sub cmdTryIt_Click()
              Dim intNumIn  As Integer
              Dim blnNumIsOdd     As Boolean
              intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
              blnNumIsOdd = IsOdd(intNumIn)
              If blnNumIsOdd Then
           Print "The number that you entered is odd."
        Else
           Print "The number that you entered is not odd."
        End If
    End Sub

    873221 wrote:
    I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
    I'm just trying to get you to think about what your post actually says, and what others will take from it.
    what does this error mean? what code should i replace and add? thanks for all response
    C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=true;
    ^
    C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=false;
    ^
    2 errors
    Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
    It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
    So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself?

  • Finally I realised that my new iPad2 is a DEMO UNIT. Thats why I can't control the appl icons. How can I turn this unit like a retail one?

    Finally I realised that my new iPad2 is a DEMO UNIT. That's why I can't control the appl icons. How can I turn this unit like a retail one?

    Tasz66 wrote:
    Yes I can't. When I try to press and hold an icon, is doesn't wiggle. Also the label at the back of the box says "...white - Demo"
    Well I guess that settles that then!
    We just wanted to make sure that you did realize that you cannot delete the preinstalled apps and you can't download them again either, so if that was the basis on which you believed that you had a demo model, we were just double checking.

  • How can I turn this line and its intersection into a separate object?

    My initial object is #1, then I draw a line on #2.
    How can I turn the highlighted area into a separate object? (I cheated and filled this area with Photoshop, but I'd like to know how to turn this red area into a separate object so that I can fill it with Illustrator)
    Thanks in advance

    Alex,
    Or you may just Pathfinder>Divide and Ungroup.

  • I just bought a new mac. I have Acrobat pro on my windows PC. How can I reinstall this program into my new mac?

    I just bought a new mac. I currently have acrobat pro X on my Windows pc that I don't intend to use any more. How can I reinstall this into my mac?

    Hi George,
    Platform swap is available only for currently shipping version products( in this case Acrobat 11)
    Please check Adobe's Platform swap policy at: Order product | Platform, language swap
    Regards,
    Rave

  • I have 8mm family footage now on a DVD how can I import this material into imovie

    Can anyone help I have old 8mm footage of the family which is now on a DVD how can I import this onto imovie?

    You need to convert the DVD .VOB files. This can be done with Apps like Handbrake or I prefer MPEG Steamclip.
    Basically what you do is insert the DVD into the drive. If DVD Player opens, quit the player. Then double click the DVD on the desktop. There you will find a folder called Video_TS. The .VOB files are there. You do not need the Audio_TS files or Folder.  So what ever App you use, point them to that Folder and convert them to highest quality conversion.
    One thing to point out though about MPEG Streamclip, you need to have Quicktime 7 installed and additionally you need a file called QuickTime MPEG-2 Playback Component. Make sure you read about it at the Squared 5 website under "Requirements". It may sound like alot of work, but once you set it up MPEG Streamclips works nice.
    Hope that gets you started.
    Additionally, if you have another machine around with Leopard or earlier, you may already have the MPEG-2 Playback Component. It would be located in /Library/Quicktime folder.

  • TS2621 I have my data retrieval se to manual. When I get mail I get a popup on the screen for each and every e-mail asking if I want to view it or cancel and I have to cancel each one before I can resume any other actions on my ipad. How can I turn this o

    I have my mail set to retrieve data manually. When I retrieve mail, I get a popup box for each and every e-mail message asking if I want to view or cancel and must either view or cancel each one before I can use other apps on the ipad. How can I turn these popups off?

    Try reset iPad (not Restore)
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • Itunes 10.5.0.142 keeps restarting itself on Windows 7, how can I turn this off?

    All of a sudden, itunes 10.5.0.142 keeps restarting itself on Windows 7.  I did not change any configuration settings on Windows.  How can I disable this?
    Thanks

    I should have posted this earlier, but anyway. I restored my laptop to factory version after backing up any useful data, and the first thing I the laptop was restored was connect to the internet, download and install the latest version of iTunes. And Bingo! It worked.
    Apple helps you find Original Sin with the Windows.

  • When trying to send a comment to a web site I get a message, Firefox has blocked this site, how can I turn this off?

    when trying to send a comment to discussion sites I get an error message that says "Firefox has blocked this site" actions offered "allow"
    or "X". When I enter "allow" it ignores the command and the message disappears. A lot of wasted thought and typing. How do I turn this feature off.

    See: Tools > Options > Advanced > General : Accessibility : [ ] "Warn me when web sites try to redirect or reload the page"
    See: [[Options window - Advanced panel#General_tab]]
    See also: http://kb.mozillazine.org/accessibility.blockautorefresh

  • Anytime I move my mouse my current window disappears. I move the mouse to the top left corner and then I comes back. How can I turn this off?

    Anytime I move my mouse my current window that is open disappears. When I move my mouse to the top left corner it comes back. How do I turn this off? It's not a Zoom issue, it disappears completely. Help please.

    Are you running 10.6 Snow Leopard as your profile indicates?
    If so, it sounds like maybe an Expose or Active Screen Corners issue?
    Go to Apple > System Preferences > Expose & Spaces > Expose and
    1. experment with the Active Screen Corners selections
    2. take a look at your F key settings for Expose
    3. lastly check your Dashboard settings

  • How can I export this pdf into a readable word?

    Dear all,
    I am trying to export the following pdf document into a word document :
    However, here is what I get: Db bte earf>eltung ber rf enntniff e, bie aum mernunf tgef d)de g ören, ben fid)eren @ang einer iff enfd)a gee ober nid)t, baß läßt fid) f>alb au bem @rfolg beurteilen. etc.
    Instead of: Ob die Bearbeitung der Erkenntnisse, die zum Vernunftgeschäft gehören, etc…
    Does anyone know how I could solve this issue?
    Thank you very much in advance,
    Pierre

    Have you started with a scanned document and then trying to go to DOCX. If so, you may have OCR set on the document before the export and it may be that the OCR can not recognize the fonts. However, the recognition appears to be based on typical block characters and I might interpret them the same way. You can try to change the primary language to German in the OCR, but that will likely not do the job. I suspect what you need is something that recognized old-German as this document appears to be (if I got the language wrong, I apologize). I am not sure Acrobat is up to the task on the type style, but is comparing to standard block characters. Some of the dedicated OCR packages might be able to do a better job.

Maybe you are looking for

  • Itunes wont open or re-install OR uninstall

    Someone PLEASE help me. My itunes did work about two weeks ago, and I know I can restore my computer to help get it fixed but I rather not. The sound stopped working one day, I restarted and the sound came back. Then after a problem with my monitor n

  • Server manager crashing - Fault Module clr.dll

    The Server manager is crashing. As soon as you try to open Server Manager it crashes instantly with the failing module being clr.dll This seems to relate to .net framework and after looking for a hotfix it says to contact Microsoft (who have been les

  • I need to report fraudulent charges from Skype. Pl...

    I got a fraudulent charge put on my card from your company at 7:43 am this morning please contact me to give my refund back. I'm not comfortable giving my acct number, however I will provide you with the last four 2193.

  • How can I setup Open Directory so that name resolution can also be achieved using a LDAPv3 server (Linux host)

    I have a Mac OS X Lion machine (macbook) which is used in a network where most machines are running Linux. Hostname resolution for local machines is achieved on the Linux boxes using a LDAP host. How can a similar behavior can be obtained on Lion (I

  • Default page display HUGE

    Just installed Firefox for Windows8. The default page display is, I'm guessing, 140%. I actually have to zoom out to get them to a normal size. Is there any sort of settings option that will let me set a smaller default display for web pages?