Hi Experts,
I am trying to get the value from a dropdown into the Invoke Command to Start a windows service in a remote system.
When I do write-host $dispname I get the value as "Some Service" but when I try to run the Invoke-Command I get the error below:
function Start-TC{
$dispname = $objAppDropDown.SelectedIt
em
write-host $dispname
Invoke-Command -Computername $objappsvrname.Text -ScriptBlock { Start-Service -DisplayName "$dispname" }
}
Error:
With "$dispname" in quotes:
Cannot bind argument to parameter 'DisplayName' because it is an empty string.
Without quotes:
Cannot bind argument to parameter 'DisplayName' because it is null.
Full script attached
scr-1.txt
Also can we send a script file to be executed in a remote system through scriptblock?
Please let me know.
Thank You!
DevSupport