Count NotReady Nodes in the Cluster

How would you go about counting the NotReady nodes in the cluster and writing that to a file?

Thanks!