Invoke-Expression与CertificateThumbprint参数不起作用

时间:2018-01-31 13:55:13

标签: powershell

我想远程让WinRM使用PowerShell监听HTTPS端口。

如果我激活" HTTPS模式"手动,我的远程命令使用此功能

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'

但是,只要我添加证书指纹,它就不再起作用了

#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"}

我猜这是没有通过的论点。

我尝试使用变量和强制转换。我尝试远程执行的命令与我手动激活HTTPS的命令完全相同,但它什么都不做。

我想念什么?

0 个答案:

没有答案