need cmdlet or ps script

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 2 years, 5 months ago.

  • Author
  • #35022

    Srikanth Byram

    $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

    Don Jones

    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.