Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to add a computer name into object

$
0
0

Can someone advise on how to approach this?

i have some code that works fine.

$Clients = (Get-QADComputer -SearchRoot "abc.forest.org/myou").name
$Range = (get-date) - (new-timespan -hour 48)
$errors = @()
foreach ($Computer in $Clients){
if (Test-Connection $Computer -Count 1 -ErrorAction SilentlyContinue){
write-host $Computer Getting Errors; $errors += Get-Winevent -ea SilentlyContinue -ComputerName $computer -FilterHashtable @{LogName="System"; Level=1,2; startTime=$Range}
}else{
write-host $Computer Failed ping
}
}

$errors


However i lose what computer the error comes from.
Any advice?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>