Like you I am always sceptical of using software commands but as you have shown it uses standard Microsoft commands and each one can be looked at to see what it does.
It only works for WiFi networks you have previously logged onto. I have found it useful when I have been on holiday, back in the office and the WiFi password has been changed as per company rules. I just go through the motions and I get the password without any fuss.