windows - Problems getting correct output in Powershell -
i'm trying make powershell script ask user input service name, run through get-service
, , show result user.
for example, if user enter vmtools
show:
status name displayname ------ ---- ----------- running vmtools vmware tools
this code:
write-host "enter service name" $servicename = read-host $result = get-service $servicename write-output "$result"
however, outputs: system.serviceprocess.servicecontroller
that because when add quotation marks around types of variables, outputs variable type, not actual contents of variable. therefore, removing quotation marks on variable output fix problem. replace last line this:
write-output $result
Comments
Post a Comment