need cmdlet or ps script

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 9 months, 4 weeks ago.

  • Author
    Posts
  • #35022
    Profile photo of Srikanth Byram
    Srikanth Byram
    Participant

    $hddts=Get-ADComputer -Filter 'name -like "hddt*"'|select -ExpandProperty name
    foreach($hddt in $hddts){if(Test-Connection -ComputerName $hddt -Count 1 -Quiet){
    $hddt|Out-File C:\Users\dt203976\Desktop\hddtpingable.txt}
    else{$hddt|Out-File C:\Users\dt203976\Desktop\hddtnotpingable.txt}
    }

    above is my script to test the connection to AD computers , my requirement is to copy all the live machines to one txt file and not in live machines to another txt file .

    but here, file name "hddtpingable.txt" is replacing existing data with current instead writing sequence , please help in correcting myscript by adding any cmdlet which fulfil my requirement

  • #35023
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Look at the help for Out-File and see if the -Append parameter has any use to your requirement.

You must be logged in to reply to this topic.