Open NikunjPatel31 opened 11 months ago
I am getting http response error: 401 - invalid content type When I tried to run "ipconfig" using RunWithString( ) after creating client with NTLM as authentication.
Sometimes it gives proper output and sometimes it gives me error.
The server I am using has NTLM enabled.
Client NetworkDelayms = 5000 URLPrefix = wsman AllowUnencrypted = false Auth Basic = false Digest = true Kerberos = true Negotiate = true Certificate = true CredSSP = false DefaultPorts HTTP = 5985 HTTPS = 5986 TrustedHosts AllowUnencrypted = false Auth Basic = false Kerberos = true Negotiate = true Certificate = false CredSSP = false CbtHardeningLevel = Relaxed DefaultPorts HTTP = 5985 HTTPS = 5986 IPv4Filter = IPv6Filter = EnableCompatibilityHttpListener = false EnableCompatibilityHttpsListener = false CertificateThumbprint
Client NetworkDelayms = 5000 URLPrefix = wsman AllowUnencrypted = false Auth Basic = false Digest = true Kerberos = true Negotiate = true Certificate = true CredSSP = false DefaultPorts HTTP = 5985 HTTPS = 5986 TrustedHosts
AllowUnencrypted = false Auth Basic = false Kerberos = true Negotiate = true Certificate = false CredSSP = false CbtHardeningLevel = Relaxed DefaultPorts HTTP = 5985 HTTPS = 5986 IPv4Filter = IPv6Filter = EnableCompatibilityHttpListener = false EnableCompatibilityHttpsListener = false CertificateThumbprint
Above are my winrm configurations
`en, err := winrm.NewEncryption("ntlm")
if err != nil { fmt.Println("Error in NewEncryption: ", err.Error()) return } params := winrm.Parameters{TransportDecorator: func() winrm.Transporter { return en }} client, err := winrm.NewClientWithParameters(endpoint, username, password, ¶ms) if err != nil { fmt.Println("Error in creating new client: ", err.Error()) return } shell, err := client.CreateShell() defer func() { err := shell.Close() if err != nil { fmt.Println("Error in closing shell: ", err.Error()) return } }() withString, s, i, err := client.RunWithString("ipconfig", "") if err != nil { fmt.Println("Error in command: ", err.Error()) return }`
@NikunjPatel31 - I have updated code, my tests work properly
I am getting http response error: 401 - invalid content type When I tried to run "ipconfig" using RunWithString( ) after creating client with NTLM as authentication.
Sometimes it gives proper output and sometimes it gives me error.
The server I am using has NTLM enabled.
Above are my winrm configurations
`en, err := winrm.NewEncryption("ntlm")