Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get-counter doesn't work after reboot in the script.

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



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