I'm writing a powershell script to get the status of some IIS sites and it works perfectly using a string as the name:
$service = (Invoke-Command -ComputerName $ComputerName {Import-Module WebAdministration; Get-WebsiteState -Name "DefaultWebsite"}).value
However when I try to pass a variable in the name it no longer works and instead now returns the statuses of all IIS sites on my server
$service = (Invoke-Command -ComputerName $ComputerName {Import-Module WebAdministration; Get-WebsiteState -Name "$serv"}).value
Nothing I seem to try resolves this issue - any advice would be appreciated!