Give helpdesk user permission to logoff RDS sessions.

I have 1'st level support staff, that I want to be able to logoff users on the terminal server.
However, I cannot seem to get this string working in powershell on the servers.
The RDS servers are Windows 2012R2.
I change domain\customgroup when executing.
Powershell is started as Administrator on the local RDS server.

(get-WmiObject -Namespace "root/cimv2/terminalservices" -Class win32_tspermissionssetting|Where-Object {$_.TerminalName -eq "RDP-Tcp"}).AddAccount("domain\customGroup",2)

Exception calling "AddAccount" : "Generic failure "
At line:1 char:1
+ (get-WmiObject -Namespace "root/cimv2/terminalservices" -Class win32_tspermissio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WMIMethodException
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phil BossmanSenior Client Systems AdminstratorCommented:
Can you give more details on your script.  Your code works fine in my environment.   Are you able to call each item individually?
mathiesen-dataAuthor Commented:
This Works, and provides output:
get-WmiObject -Namespace "root/cimv2/terminalservices" -Class win32_tspermissionssetting

The pipe, seems to be the problem:
Where-Object {$_.TerminalName -eq "RDP-Tcp"}).AddAccount("domain\customGroup",2)

This is the systeminfo:
Host Name:                 DOMAINTERM1
OS Name:                   Microsoft Windows Server 2012 R2 Standard
OS Version:                6.3.9600 N/A Build 9600
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Server
OS Build Type:             Multiprocessor Free
Registered Owner:          Windows User
Registered Organization:
Product ID:                00252-40200-36457-AAOEM
Original Install Date:     03-06-2014, 12:43:27
System Boot Time:          08-06-2015, 03:36:52
System Manufacturer:       Microsoft Corporation
System Model:              Virtual Machine
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 62 Stepping 4 GenuineIntel ~2594 Mhz
BIOS Version:              American Megatrends Inc. 090006 , 23-05-2012
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             da;Danish
Input Locale:              da;Danish
Time Zone:                 (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
Total Physical Memory:     8.000 MB
Available Physical Memory: 6.510 MB
Virtual Memory: Max Size:  9.280 MB
Virtual Memory: Available: 7.595 MB
Virtual Memory: In Use:    1.685 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    domain.local
Logon Server:              \\DOMAINDC
Hotfix(s):                 110 Hotfix(s) Installed.
mathiesen-dataAuthor Commented:
Created a new Group without the characters _ and - in them. That solved it.
Phil BossmanSenior Client Systems AdminstratorCommented:
If changing the group name solves your problem, then your original problem may have been the group.  I've tried in my lab, a group with both _ and - and still can't reproduce an error.  

Glad to hear it's been resolved

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2012

From novice to tech pro — start learning today.