disconnect-vpnuser error. (Powershell, RRAS)

%3CLINGO-SUB%20id%3D%22lingo-sub-2203440%22%20slang%3D%22en-US%22%3Edisconnect-vpnuser%20error.%20(Powershell%2C%20RRAS)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2203440%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20disconnect%20a%20user%20from%20a%20RRAS%20VPN%20Server%20with%20the%20below%20PowerShell%20command%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Edisconnect-vpnuser%20-username%20domain%5Cusername%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20I%20get%20the%20below%20error%20when%20the%20command%20is%20run.%26nbsp%3B%20The%20user%20is%20definitely%20connected%20to%20the%20VPN.%26nbsp%3B%20Has%20anyone%20got%20a%20remedy%20for%20the%20below%20error%20when%20running%20disconnect-vpnuser%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Edisconnect-vpnuser%20%3A%20User%20domain%5Cusername%20cannot%20be%20disconnected.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20disconnect-vpnuser%20-UserName%20domain%5Cusername%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20NotSpecified%3A%20(domain%5Cusernamenc%3Aroot%2FMicrosoft%2F...ces%3CBR%20%2F%3Es%2FPS_VpnUser)%20%5BDisconnect-VpnUser%5D%2C%20CimException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20REMOTEACCESS%20200%2CDisconnect-VpnUser%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2203440%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ERRAS%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2204381%22%20slang%3D%22en-US%22%3ERe%3A%20disconnect-vpnuser%20error.%20(Powershell%2C%20RRAS)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2204381%22%20slang%3D%22en-US%22%3EWhich%20Windows%20version%20are%20you%20using.%3CBR%20%2F%3EType%20the%20following%20commands%20after%20you%20get%20the%20failure.%3CBR%20%2F%3E%3CBR%20%2F%3E%24error.CategoryInfo%3CBR%20%2F%3E%24error.Exception%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you%20used%20the%20GUI%2C%20are%20able%20to%20disconnect%20the%20user%3CBR%20%2F%3EAlso%20when%20you%20can%20the%20error%20from%20Windows%20PowerShell%2C%20did%20you%20check%20Windows%20Event%20Log%20%5C%20PowerShell%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205513%22%20slang%3D%22en-US%22%3ERe%3A%20disconnect-vpnuser%20error.%20(Powershell%2C%20RRAS)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205513%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F790105%22%20target%3D%22_blank%22%3E%40farismalaeb%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20reply.%26nbsp%3B%20When%20I%20run%20the%20commands%20you%20suggested%20here%20is%20what%20I%20get%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24error.categoryinfo%3CBR%20%2F%3ECategory%20%3A%20NotSpecified%3CBR%20%2F%3EActivity%20%3A%20Disconnect-VpnUser%3CBR%20%2F%3EReason%20%3A%20CimException%3CBR%20%2F%3ETargetName%20%3A%20thrws%3CBR%20%2F%3ETargetType%20%3A%20root%2FMicrosoft%2FWindows%2FRemoteAccess%2FPS_VpnUser%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24error.exception%3CBR%20%2F%3EUser%20thrws%20cannot%20be%20disconnected.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20using%20Windows%20Server%202012R2%20and%20yes%20I%20can%20disconnect%20them%20from%20the%20RRAS%20Console.%26nbsp%3B%20There%20are%20no%20errors%20in%20the%20Event%20Viewer%20for%20Powershell.%26nbsp%3B%20Any%20help%20would%20be%20greatly%20appreciated.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205643%22%20slang%3D%22en-US%22%3ERe%3A%20disconnect-vpnuser%20error.%20(Powershell%2C%20RRAS)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205643%22%20slang%3D%22en-US%22%3EToday%20I%20installed%20Universal%20C%20Runtime%20and%20also%20installed%20PowerShell%207.1.3%20and%20I%20still%20get%20the%20same%20errors.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2208143%22%20slang%3D%22en-US%22%3ERe%3A%20disconnect-vpnuser%20error.%20(Powershell%2C%20RRAS)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2208143%22%20slang%3D%22en-US%22%3E%3CP%3EPowerShell%20will%20use%20some%20CIM%20classes%20to%20do%20this%20task%2C%20lets%20try%20it%20and%20run%20the%20following%20command%20in%20the%20RRAS%20Server%20itself%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%24xArg%3D%40%7B%0AComputerName%20%3D%24null%0APassThru%20%3D%20%24null%0AUserName%20%3D%20%40('DOMAIN%5CTheUserName')%0A%7D%0AInvoke-CimMethod%20-ClassName%20PS_VpnUser%20-Namespace%20%22Root%5CMicrosoft%5CWindows%5CRemoteAccess%22%20-MethodName%20%22DisconnectByUserName%22%20-Arguments%20%24xArg%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CBR%20%2F%3EBtw%2C%20are%20you%20using%20Microsoft%20Direct%20Access%20or%20its%20just%20an%20RRAS%3CBR%20%2F%3E%3CBR%20%2F%3ELet%20me%20know%20if%20the%20command%20above%20disconnects%20the%20user.%3CBR%20%2F%3Ein%20the%20background%2C%20this%20is%20what%20PowerShell%20should%20be%20calling.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2210014%22%20slang%3D%22en-US%22%3ERe%3A%20disconnect-vpnuser%20error.%20(Powershell%2C%20RRAS)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2210014%22%20slang%3D%22en-US%22%3EThanks%20for%20the%20reply%20again.%20When%20I%20run%20the%20script%20that%20you%20provided%20I%20get%20the%20below%20error.%20Similar%20to%20what%20I%20get%20in%20running%20disconnect-vpnuser.%20I%20am%20using%20just%20VPN%20without%20Direct%20Access.%20The%20sad%20thing%20is%20I%20have%20used%20disconnect-vpnuser%20on%20this%20server%20before.%20I'm%20using%20a%20standard%20phonebook%20entry%20for%20the%20user%20to%20connect%20via%20SSTP%20to%20the%20VPN.%20I%20have%20rebuilt%20WMI%2C%20disabled%20RRAS%20and%20reinstalled%20with%20the%20default%20settings.%20I%20have%20even%20built%20a%20new%20server%20that%20even%20gives%20the%20same%20error.%20At%20this%20point%20I'm%20looking%20into%20Group%20Policy%20settings%20to%20see%20if%20something%20is%20causing%20this%20error.%3CBR%20%2F%3E%3CBR%20%2F%3EInvoke-CimMethod%20%3A%20User%20tyeshouse%5Cthrwnc%20cannot%20be%20disconnected.%3CBR%20%2F%3EAt%20line%3A6%20char%3A1%3CBR%20%2F%3E%2B%20Invoke-CimMethod%20-ClassName%20PS_VpnUser%20-Namespace%20%22Root%5CMicrosoft%5CWindows%5CRemote%20...%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20NotSpecified%3A%20(tyeshouse%5Cthrwnc%3A)%20%5BInvoke-CimMethod%5D%2C%20CimException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20REMOTEACCESS%20200%2CMicrosoft.Management.Infrastructure.CimCmdlets.InvokeCimMetho%3CBR%20%2F%3EdCommand%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EPSComputerName%3CBR%20%2F%3E--------------%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2210266%22%20slang%3D%22en-US%22%3ERe%3A%20disconnect-vpnuser%20error.%20(Powershell%2C%20RRAS)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2210266%22%20slang%3D%22en-US%22%3Ewould%20you%20please%20check%20windows%20update%20history%3F%3CBR%20%2F%3Ewhen%20this%20command%20last%20time%20was%20working%20and%20the%20installed%20update%20after%20that%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

 

I'm trying to disconnect a user from a RRAS VPN Server with the below PowerShell command:

 

disconnect-vpnuser -username domain\username

 

However, I get the below error when the command is run.  The user is definitely connected to the VPN.  Has anyone got a remedy for the below error when running disconnect-vpnuser:

 

disconnect-vpnuser : User domain\username cannot be disconnected.
At line:1 char:1
+ disconnect-vpnuser -UserName domain\username
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (domain\username:root/Microsoft/...ces
s/PS_VpnUser) [Disconnect-VpnUser], CimException
+ FullyQualifiedErrorId : REMOTEACCESS 200,Disconnect-VpnUser

9 Replies
Which Windows version are you using.
Type the following commands after you get the failure.

$error.CategoryInfo
$error.Exception

If you used the GUI, are able to disconnect the user
Also when you can the error from Windows PowerShell, did you check Windows Event Log \ PowerShell

@farismalaeb 

 

Thanks for the reply.  When I run the commands you suggested here is what I get:

 

$error.categoryinfo
Category : NotSpecified
Activity : Disconnect-VpnUser
Reason : CimException
TargetName : thrws
TargetType : root/Microsoft/Windows/RemoteAccess/PS_VpnUser

 

$error.exception
User thrws cannot be disconnected.

 

I'm using Windows Server 2012R2 and yes I can disconnect them from the RRAS Console.  There are no errors in the Event Viewer for Powershell.  Any help would be greatly appreciated.

Today I installed Universal C Runtime and also installed PowerShell 7.1.3 and I still get the same errors.

PowerShell will use some CIM classes to do this task, lets try it and run the following command in the RRAS Server itself

$xArg=@{
ComputerName =$null
PassThru = $null
UserName = @('DOMAIN\TheUserName')
}
Invoke-CimMethod -ClassName PS_VpnUser -Namespace "Root\Microsoft\Windows\RemoteAccess" -MethodName "DisconnectByUserName" -Arguments $xArg


Btw, are you using Microsoft Direct Access or its just an RRAS

Let me know if the command above disconnects the user.
in the background, this is what PowerShell should be calling.

Thanks for the reply again. When I run the script that you provided I get the below error. Similar to what I get in running disconnect-vpnuser. I am using just VPN without Direct Access. The sad thing is I have used disconnect-vpnuser on this server before. I'm using a standard phonebook entry for the user to connect via SSTP to the VPN. I have rebuilt WMI, disabled RRAS and reinstalled with the default settings. I have even built a new server that even gives the same error. At this point I'm looking into Group Policy settings to see if something is causing this error.

Invoke-CimMethod : User domain\user cannot be disconnected.
At line:6 char:1
+ Invoke-CimMethod -ClassName PS_VpnUser -Namespace "Root\Microsoft\Windows\Remote ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (domain\user:) [Invoke-CimMethod], CimException
+ FullyQualifiedErrorId : REMOTEACCESS 200,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMetho
dCommand


PSComputerName
--------------

would you please check windows update history?
when this command last time was working and the installed update after that

No updates have been installed since 2017. The command was working prior to some firewall rule changes and enabling Certificate Enrollment.

 

I'm currently building a new RRAS using only the Windows 2012 R2 ISO.

I found my problem. I want to thank you again for replying and offering help.

I have a unique setup going on with my VPN where I'm assigning users static IP Addresses through the Active Directory Dial-In properties. I'm also using Radius with a Network Policy Server. My problem was the NPS Policy. On the VPN I have Inbound and Outbound rules set on each NIC. I also had IP Filters enabled on my NPS Policy with the same settings. Once I removed the IP Filters from the NPS Policy I was able to use disconnect-vpnuser successfully.
That's good news, glad your issue was resolved and you post the answer back.