We have a problem where the network location profile unexpectedly changes from Domain to Public. This jazzes up some client web apps.
To remedy this we bounce the "Network Location Awareness"service.
To identify servers with the problem we run:
netsh advfirewall monitor show current profile
If the return contains the string "Unidentified network" then the correct network profile is not present..
I could code up something that runs once a day and sends the results of the netsh call to a text file and then parse the file but would like to have relevance do the interogating.
How can I interrogate the firewall in relevance to return true if "Undefined network is the network profile?