VMware Cloud Community
IKirill
Enthusiast
Enthusiast
Jump to solution

Invoke-VMScript to disable Remote Desktop Network Level Authentication

Hi comrades!

I need a liitle help)

I have this

Invoke-VMScript -vm $vm -GuestUser Administrator -GuestPassword NewYork2017! -ScriptType Powershell -Scripttext "(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -ComputerName $env:computername -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0)"

The output:

Invoke-VMScript : A positional parameter cannot be found that accepts argument 'Win32_TSGeneralSetting -Namespace root\cimv2\terminalservices -ComputerName 00-TSNST -Filter Termin

alName=RDP-tcp).SetUserAuthenticationRequired(0)''.

notes:

1. If i run in windows server 2012r2 command "Get-WmiObject -class "Win32_TSGeneralSetting"".... ITS OK

2. The color line in PS ISE is variable, Not brown

3. In output "00-TSNST" is my local station

Thanks!

Remote Desktop Network Level Authentication using ...

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I suspect this might be a quote thing.

Try placing the code in a here-string, delimited with single quotes so there is no substitution happening.

Something like this

$code = @'

(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -ComputerName $env:computername -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0)

'@

Invoke-VMScript -vm $vm -GuestUser Administrator -GuestPassword NewYork2017! -ScriptType Powershell -Scripttext $code


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

I suspect this might be a quote thing.

Try placing the code in a here-string, delimited with single quotes so there is no substitution happening.

Something like this

$code = @'

(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -ComputerName $env:computername -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0)

'@

Invoke-VMScript -vm $vm -GuestUser Administrator -GuestPassword NewYork2017! -ScriptType Powershell -Scripttext $code


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
IKirill
Enthusiast
Enthusiast
Jump to solution

Thanks LucD!

You are right!

The problem is in the quote.

I add a commentary for each quote and ITS works too))))

Invoke-VMScript -vm $vm -GuestUser Administrator -GuestPassword NewYork2017! -ScriptType Powershell -Scripttext "(Get-WmiObject -Class `"Win32_TSGeneralSetting`" -Namespace root\cimv2\TerminalServices -Filter `"TerminalName='RDP-tcp'`").SetUserAuthenticationRequired(0) | Out-Null"

Reply
0 Kudos