Assign a Get-WebAppPoolState returned value to a variable in Powershell -
this code:
import-module webadministration
get-webapppoolstate apppoolname
produces following output:
value - -
stopped
but code:
import-module webadministration
$state = get-webapppoolstate apppoolname
write-host $state
produces output:
microsoft.iis.powershell.framework.codeproperty
when state of app pool using get-webapppoolstate, need boolean value of sort assign variable can use in conditional statement.
i cant use microsoft.iis.powershell.framework.codeproperty line.
how correct this?
get-webapppoolstate not returning string object of type codeproperty. you'll want value property object, i.e.:
$state = (get-webapppoolstate apppoolname).value;
i presume display converter kicking in first case when gets written output why stopped displayed not writing host default object representation (which type name) instead.
Comments
Post a Comment