$myService = get-service -Name Spool*
If I try to change service status, my variable is not change in my case. How to create a ref for a concrete obj?
$myService = get-service -Name Spool*
If I try to change service status, my variable is not change in my case. How to create a ref for a concrete obj?
When you use Get-Service, you get an object containing all kinds of properties from that service at the time the cmdlet ran, like Status.
If after that you change the status of that service, the variable used to capture the status before is not altered automagically.
Therefore you have to run Get-Service again to refresh that information.