I have trouble with following piece of code:
$result = "F651F545A059588ABFDCE7EE3EEB27EED8CED28D"
winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname="my.host.winagent"; CertificateThumbprint="$result"}'
it yields:
Message = The WS-Management service cannot process the configuration request because the certificate thumbprint in the request is not a valid hex string: $result.
it looks like variable result is not being expanded, probably because it is inside array? How to get the variable value expanded there?
You need to use "
(not '
) to create an expandable string literal - escape the literal "
's by doubling them:
winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=""my.host.winagent""; CertificateThumbprint=""$result""}"