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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -