Is there a bug with Get-counter for remote machine where it won’t collect data after reboot?
$server=“server01”
try {$TQRS1= (Get-Counter-ComputerName$server-Counter"\DNS\Total Query Received/Sec"-MaxSamples5 -ErrorActionstop).countersamples.cookedvalue }
catch {Write-Warning"Unable to collect Total Query Received/Sec data for$server... "}
Restart-Computer-ComputerName$server-Force-Wait -ForWinRM
try {$TQRS1= (Get-Counter-ComputerName$server-Counter"\DNS\Total Query Received/Sec"-MaxSamples5 -ErrorActionstop).countersamples.cookedvalue }
catch {Write-Warning"Unable to collect Total Query Received/Sec data for$server... "}
The code returns an error for Get-counter after reboot in this script. As a workaround I used Invoke-command to the remote computer and collect the get-counter data.
99upgrade