# need cmdlet or ps script

**URL:** <https://forums.powershell.org/t/need-cmdlet-or-ps-script/5735>\
**Category:** PowerShell Help\
**Created:** [February 8, 2016, 12:34pm UTC](https://forums.powershell.org/t/need-cmdlet-or-ps-script/5735 "2016-02-08T12:34:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![srikanth-byram](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@srikanth-byram](https://forums.powershell.org/u/srikanth-byram)\
**Post date:** [February 8, 2016, 12:34pm UTC](https://forums.powershell.org/t/need-cmdlet-or-ps-script/5735/1 "2016-02-08T12:34:57Z")

</div>

$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

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [February 8, 2016, 12:48pm UTC](https://forums.powershell.org/t/need-cmdlet-or-ps-script/5735/2 "2016-02-08T12:48:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:42pm UTC](https://forums.powershell.org/t/need-cmdlet-or-ps-script/5735/3 "2024-05-16T20:42:57Z")

</div>

Closed on May 16, 2024, 8:42pm UTC


