Agreed with your point - we should drag the machine in the state we want. But in my case the number 1 priority is to make the script idempotent, which seems like quite a thing on windows end.
I not installing anything on the windows end and my application will run as standalone service, no installation required. I am using NSSM to install the services, so win_package is not going to be of any use to me.
To make my script idempotent, i must first check if the service exists, before i invoke NSSM to create the service. I can live with the complicated conditionals i will have in my scripts, but they must be idempotent in the end.
The solution where i check the service with win_service works fine except that in the case it is not present, it will give me a lot of red statements. What i am looking for is a better way where i can simply check that if a given service is created or not. I wish NSSM had some API to check for that.