Stop/disable sensor with switch?

I am using an sensor that wil only work when my pc is turned on, so if I turn of my pc I will get error’s saying that the sensor cannot reach the pc’s Ip address. So is there a way to turn the sensors of with a switch, I would like to make an automation that if my pc is turned off it turns the switch of the sensor to off.