I want to remotely make WinRM listen to the HTTPS port using PowerShell.
If I activate the "HTTPS mode" manually, my remote command works well using this function
function Execute-Remote {
[CmdletBinding()]
Param(
[Parameter(mandatory=$true)][String]$command
)
Process {
$finalCommand = "start cmd.exe '/C " + $command + "'"
Invoke-Expression -Command $finalCommand
return $finalCommand
}
}
#Works
Execute-Remote "WinRM delete winrm/config/Listener?Address=*+Transport=HTTPS"
#Command sent : start cmd.exe '/C WinRM delete winrm/config/Listener?Address=*+Transport=HTTPS'
But, as soon as I add the certificate thumbprint, it doesn't work anymore
#Doesn't work
Execute-Remote 'winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{CertificateThumbprint="example"}'
#Command sent start cmd.exe '/C winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{CertificateThumbprint="example"}
I guess that it is the argument that doesn't pass.
I tried using variables and casts. The command that I try to execute remotely is exactly the same as the one I use to activate HTTPS manually but it does nothing.
What do I miss?