banner



How To Allow Remote Desktop Connection Windows Server 2012 R2

Enable Remote Desktop on Windows Server 2012 R2 via PowerShell

Latest Windows Server products come with Windows Remote Management (WinRM) enabled by default, but traditional Remote Desktop (RDP) feature is disabled. If y'all always need to enable remote desktop feature on your newly deployed Windows Server 2012 R2 box but you don't have console admission, you tin can do so past using Windows PowerShell. In this guide I will tell you how to enable remote desktop when in that location is no console access to server.Terminal Services Connection SettingsBefore starting, you should know the Registry value which controls the Remote Desktop aka Last Services connections in Microsoft Windows (Servers and Clients). There is a DWORD value named "fDenyTSConnections" within 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server'. This primal accepts boolean value (either 0 or 1) and information technology is one by default which means Remote Desktop connectedness is disabled. By using elementary PowerShell commands nosotros will connect to remote server using WS-Management protocol and prepare this value to 0. We will likewise create and enable a dominion in Windows Firewall to accept RDP connections.

Enable Remote Desktop Feature

Launch Windows PowerShell on your PC and blazon the post-obit command:

Invoke-Control  -ComputerName MyDC1 -ScriptBlock {Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Command\Last Server' -Name "fDenyTSConnections" -Value 0 -Verbose}

Supersede MyDC1 with your ain computer proper name. If your currently logged on user does not take enough privilege to modify Windows registry on remote figurer, y'all tin specify -Credential domain\admin and the command will be run every bit alternate user

Add Rule To Windows Firewall

Type the following command in Windows PowerShell:

Invoke-Command  -ComputerName MyDC1 -ScriptBlock {Enable-NetFirewallRule -DisplayGroup "Remote Desktop" -Verbose}

That'due south all. Now your server will exist accepting remote desktop connections.

I have created a Windows PowerShell module for this chore. If you want to prepare it in your computer and run it like traditional PowerShell cmdlet, follow the steps below

Create Windows PowerShell Module

Open Windows PowerShell ISE or notepad or whatsoever other text editor of your choice and re-create the following code:

          <#                      .Synopsis                      Enables the remote desktop feature          .Description                      The Enable-RemoteDesktop Cmdlet enables the remote desktop feature on remote computer(s) using the credentials of logged-on user or alternate user account specified in -Credential parameter          .Parameter                                This is a required parameter where you need to specify a computer name which tin can exist localhost or a remote reckoner          .Parameter                                This is an optional parameter where you lot can specify alternate credentials to connect to remote reckoner if your current user account does not have enough privilege to make changes to Windows registry of remote reckoner          .Example                      Enable-RemoteDesktop -ComputerName DC1                      This command will enable the remote desktop feature on DC1          .Example                      Enable-RemoteDesktop -ComputerName DC1 -Credential mydomain\admin                      This command will enable the remote desktop feature on DC1 using domain admin credentials                      #>                      Role Enable-RemoteDesktop {          [CmdletBinding()]                      param(                      [Parameter(Mandatory=$true)]                      [String[]]$ComputerName='localhost',                      [System.Management.Automation.CredentialAttribute()]                      $Credential                      )                      Invoke-Command  -ComputerName $ComputerName -ScriptBlock {Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Proper noun "fDenyTSConnections" -Value 0 -Verbose}                      Invoke-Command  -ComputerName $ComputerName -ScriptBlock {Enable-NetFirewallRule -DisplayGroup "Remote Desktop" -Verbose}                      }        

Create a folder named "Windows PowerShell" in your [My] Documents folder.

Create another folder named "Modules" inside Windows PowerShell folder.

Create another binder named "Enable-RemoteDesktop" inside Modules folder.

Save the lawmaking copied to notepad into Enable-RemoteDesktop binder with the name "Enable-RemoteDesktop.psm1" filename. Note the file extension should be .psm1 which will make information technology a PowerShell module.

Now open Windows PowerShell console on your PC and blazon the post-obit control:

          Get-Help Enable-RemoteDesktop -Full        

You will notice that y'all have merely created a Windows PowerShell cmdlet that will feel and carry like other cmdlets. You can utilize parameters like -ComputerName, -Credential, -Verbose, -ErrorAction etc. which is awesome.

Below is the snapshot of Get-Help Enable-RemoteDesktop -Full command:

          NAME              Enable-RemoteDesktop          SYNOPSIS              Enables the remote desktop characteristic          SYNTAX              Enable-RemoteDesktop [-ComputerName] <Cord[]> [[-Credential] <Object>] [<CommonParameters>]          Description              The Enable-RemoteDesktop Cmdlet enables the remote desktop characteristic on remote computer(s) using the credentials of logged-on              user or alternate user account specified in -Credential parameter          PARAMETERS              -ComputerName <Cord[]>                  Required?                    truthful                  Position?                    ane                  Default value                localhost                  Have pipeline input?       faux                  Have wildcard characters?  faux              -Credential <Object>                  Required?                    false                  Position?                    ii                  Default value                  Accept pipeline input?       false                  Accept wildcard characters?  false              <CommonParameters>                  This cmdlet supports the common parameters: Verbose, Debug,                  ErrorAction, ErrorVariable, WarningAction, WarningVariable,                  OutBuffer, PipelineVariable, and OutVariable. For more information, run into                  about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).          INPUTS          OUTPUTS              -------------------------- EXAMPLE 1 --------------------------              PS C:\>Enable-RemoteDesktop -ComputerName DC1              This command will enable the remote desktop feature on DC1              -------------------------- Case 2 --------------------------              PS C:\>Enable-RemoteDesktop -ComputerName DC1 -Credential mydomain\admin              This command will enable the remote desktop feature on DC1 using domain admin credentials          RELATED LINKS        

At present whenever you desire y'all can enable remote desktop on whatever remote calculator past using following command:

Enable-RemoteDesktop -ComputerName MyDC2

If your currently logged on user does not accept enough privilege for remote computer, yous tin add together -Credential parameter and supply your domain admin credentials as shown beneath:

Enable-RemoteDesktop -ComputerName MyDC2 -Credential domain\admin

Yous will be prompted to enter the credentials on the wing as shown in following image

This is how you tin enable remote desktop characteristic without having panel access to remote server. Windows Server 2012 and later version of Windows Server family unit comes with Windows Remote Management enabled by default. In earlier versions of Windows Server, you take to enable Remote Direction earlier you lot tin can utilise these PowerShell commands. For more information on how to enable Windows PowerShell Remoting, visit this page.

You tin utilize this guide to enable remote desktop selection in whatever version of windows including Windows seven, Windows 10, Server 2008 R2 etc.

BACK

Source: https://www.techtutsonline.com/enable-remote-desktop-on-windows-server-2012-r2-via-powershell/

Posted by: milneribrat1997.blogspot.com

0 Response to "How To Allow Remote Desktop Connection Windows Server 2012 R2"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel