Finding the Funny Side of RDP Port Shenanigans

We start our adventure with a code snippet that aims to, of all things, change the RDP port on a Windows server. Now, for those of you who might be wondering, “Why on Earth would someone want to do that?” Well, let’s just say that sometimes, in the vast world of IT, we like to keep things spicy. And what’s spicier than changing a port number? Okay, maybe a lot of things, but bear with me.

 

**Step 1:** _The Great Port Reveal_

    

    

    powershell

    

    

    # Retrieve Current RDP Port

    Get-ItemProperty -Path “HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\” -Name PortNumber | Select-Object PortNumber

    

 

This is like asking your server, “Hey buddy, which door should I knock on if I want to RDP into you?” And the server, being the polite entity it is, responds with the port number. It’s like asking your friend for their home address, but in a more techy way.

 

**Step 2:** _The Port Switcheroo_

    

    

    powershell

    

    

    # Change RDP Port to 3332

    Set-ItemProperty -Path “HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\” -Name PortNumber -Value 3332

    

 

This is where the mischief happens. Imagine telling your friend, “Hey, I know you live at 123 Main St., but how about tomorrow you magically move to 3332 NotMain St.?” That’s essentially what we’re doing here. We’re telling the server, “Hey, I know you’re used to this, but let’s shake things up a bit!”

 

**Step 3:** _The Firewall Fashion Show_

    

    

    powershell

    

    

    # Create Firewall Rules for the New RDP Port

    New-NetFirewallRule -DisplayName “Remote Desktop – User Mode (TCP-In) 3332” -Direction Inbound –Protocol TCP -Profile Any –LocalPort 3332 -Action allow

    New-NetFirewallRule -DisplayName “Remote Desktop – User Mode (UDP-In) 3332” -Direction Inbound –Protocol UDP -Profile Any –LocalPort 3332 -Action allow

    

 

Now, changing your address is one thing, but you also need to tell the postman where the new mailbox is. These commands are like setting up a neon sign that says, “Hey, deliveries over here!” But instead of packages, we’re talking about network packets.

 

**Step 4:** _The Moment of Truth (or Regret)_

    

    

    powershell

    

    

    # Prompt for Restart

    [ValidateSet(‘Yes’,’No’)]$Answer = Read-Host “`nAre you sure you want to restart the server? Enter Yes/No”

    If ($Answer -eq ‘Yes’) { Restart-Computer -Force }

    

 

This is the equivalent of asking, “Are you REALLY sure you want to wear those neon green pants to the party?” It’s a final sanity check. And if you’re feeling brave (or just love neon green), you go for it and restart that server!

 

In conclusion, while changing an RDP port might seem like a mundane task to some, with a little imagination, it can be a thrilling adventure. So the next time you’re diving into some code, remember to find the funny side. It makes the journey all the more enjoyable!

Leave a Reply

Your email address will not be published. Required fields are marked *