So I am fairly new at PowerShell and I am trying to do something that seems like it should be very simple but I have not been able to find any way to do it or anything on the internet. Honestly I think that might be more because I am unfamiliar with the terminology. Anyways here goes:
All I am trying to do is get Set-Service to use user input to target which service it would like to use. I thought this would be as simple as
Start-Service -Name $Services
But it always comes back as null.
and I am using
$Services = Read-Host "Service Name"
to define $Service, also I have attempted to use $Service as a string which seemed like it was causing the issue but it always came back as string empty.
I believe this is because I am not using the correct data type but I am unsure. If someone could help me with this simple problem I would greatly applicate it. It really annoying that something that seems like it should be very simple is causing me so much trouble.
Thanks,
Edit: Also I should add the full line I am attempting is
Invoke-Command -ComputerName $Server -Credential $UserCreds -ScriptBlock {Start-Service -Name $Services}