r/CyberARk • • Jul 13 '17

PSM-RDP Batch File

Just a little batch file for loading up a 'native' RDP session with PSM. Edit the domain/psmAddr variables at the top, and away you go.

"Features" (If you can call them that):

  • End-user specifies the hostname they want to connect to each time
  • End-User specifies the ID they are using, so in the event they try to use a shared account that's in use, they can run it again and specify a different one
  • Prompts/parameter for "local" or "domain" based account for proper PSM call
  • Can be called from command, parameterized
  • You can just double-click it as well, it will prompt for the required info
  • Creates/deletes the required RDP file automatically

@echo off

set domain=corp.contoso.com
set psmAddr=psm.corp.contoso.com

if "%1" == "" goto prompt
if "%2" == "" goto prompt
if "%3" == "" goto prompt
if "%4" == "" goto prompt

if "%3" == "0" (
 echo alternate shell:s:psm /u %2@%domain% /a %1 /c %4
) > %1.rdp

if "%3" == "1" (
 echo alternate shell:s:psm /u %2 /a %1 /c %4
) > %1.rdp

(
 echo connection type:i:3
 echo full address:s:%psmAddr%
 echo authentication level:i:0
 echo enablecredsspsupport:i:0
 echo negotiate security layer:i:1
 echo desktopwidth:i:1280
 echo desktopheight:i:800
 echo screen mode id:i:1
 echo disable wallpaper:i:1
 echo PromptCredentialOnce:i:0
 echo winposstr:s:0,0,0,0,1400,1000
) >> %1.rdp

mstsc.exe %1.rdp

del %1.rdp

goto end

:prompt

set /p server=Enter the server: 
set /p adminID=Enter the admin ID: 
set /p connectComp=Enter the connection component [Ex; PSM-RDP]:

:environment
set /p env=Enter 0 for domain or 1 for local: 
if "%env%" == "0" (
 echo alternate shell:s:psm /u %adminID%@%domain% /a %server% /c %connectComp% > %server%.rdp
 goto runRDP
)

if "%env%" == "1" (
 echo alternate shell:s:psm /u %adminID% /a %server% /c %connectComp% > %server%.rdp
 goto runRDP
)

goto environment

:runRDP
(
 echo connection type:i:3
 echo full address:s:%psmAddr%
 echo authentication level:i:0
 echo enablecredsspsupport:i:0
 echo negotiate security layer:i:1
 echo desktopwidth:i:1280
 echo desktopheight:i:800
 echo screen mode id:i:1
 echo disable wallpaper:i:1
 echo PromptCredentialOnce:i:0
 echo winposstr:s:0,0,0,0,1400,1000
) >> %server%.rdp

mstsc.exe %server%.rdp

del %server%.rdp

:end
4 Upvotes

3 comments sorted by

2

u/yanni Guardian Jul 17 '17

Hey man - this is great - I am going to steal it, and claim to have come up with it :D. But in all seriousness great work - I need to add the ability to switch out the PSM-RDP connection component for others (as options), but this is a perfect baseline.

2

u/CyberArkAnon Jul 18 '17

There, added connection component changes.

nudge nudge wink wink this would probably be good link in sidebar i'm just saying.

1

u/diogosabino Apr 25 '25

Bom trabalho! Funciona muito bem, tanto pra rdp quanto pra ssh.