VSphere Web - AutoIT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VSphere Web - AutoIT

L5 Sessionator

My customer is using VSphere Web (6.0) and its enabled with flash plugin.

prepared a custom connector using AutoIT, its working in the local server but when deployed into PSM Server its not working as in the local server.

 

Any has some working code? or some help around this script would be much appreciated

#AutoIt3Wrapper_UseX64=n   Opt("MustDeclareVars", 1)   AutoItSetOption("WinTitleMatchMode",2) ; EXACT_MATCH!     ;============================================================ ; PSM AutoIt Dispatcher Skeleton ; ------------------------------ ; ; Use this skeleton to create your own ; connection components integrated with the PSM. ; Areas you may want to modify are marked ; with the string "CHANGE_ME". ; ; Created : July 2018 ; Kloud Solutions ;============================================================ #include "PSMGenericClientWrapper.au3" ;======================================= ; Consts & Globals ;======================================= #include <PSMGenericClientWrapper.au3>   #include <GuiMenu.au3> #include <IE.au3> #include <Inet.au3>   Global $ConnectionClientPID = 0   Global Const $DISPATCHER_NAME = "PSM-VMWareWeb-IE"     Global Const $CLIENT_EXECUTABLE = "C:\Program Files\internet explorer\iexplore.exe" ; CHANGE_ME - Nirmal   Global Const $ERROR_MESSAGE_TITLE = "PSM " & $DISPATCHER_NAME & " Dispatcher error message"   Global Const $LOG_MESSAGE_PREFIX = $DISPATCHER_NAME & " Dispatcher - "     Global $TargetUsername   Global $TargetPassword   Global $TargetAddress   Global $ConnectionClientPID = 0   Global $oIE   Global $url="SYDHDCVM05-VCS.corp.qf.qantas.com.au/vsphere-client"   ;======================================= ; Code ;======================================= Exit Main()   ;======================================= ; Main ;======================================= Func Main()   ToolTip ("Initializing...")   if (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then   Error(PSMGenericClient_PSMGetLastErrorString())   EndIf   LogWrite("successfully initialized Dispatcher Utils Wrapper - QMC Portal")   FetchSessionProperties()   LogWrite("mapping local drives - IdentityNow")   if (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then Error(PSMGenericClient_PSMGetLastErrorString()) EndIf       LogWrite("starting client application") ToolTip("Starting " & $DISPATCHER_NAME & "...")   $oIE=_IECreate() Sleep(500) LogWrite(" == Nirmal LOG Starts 2==== ")   _IENavigate($oIE, $url, 0)     local $title = WinGetTitle("vSphere Web Client - Internet Explorer") LogWrite($title)   WinWaitActive("[CLASS:Credential Dialog Xaml Host]","", 10)   If WinExists("[CLASS:Credential Dialog Xaml Host]") Then sleep(100) ClipPut(" ") sleep(100) ClipPut($TargetUsername) sleep(100) Send("^v") Send("{TAB}") sleep(200) ClipPut(" ") ClipPut($TargetPassword) sleep(250) Send("^v") send("{TAB}") sleep(100) sleep(100) send("{ENTER}")   Else LogWrite(" Nirmal LOG Starts ELSE PART ") EndIf $ConnectionClientPID = WinGetProcess("[CLASS:IEFrame]")   ToolTip("PID " & $ConnectionClientPID & "") if ($ConnectionClientPID == 0) Then Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error)) EndIf   ; Send PID to PSM as early as possible so recording/monitoring can begin LogWrite("sending PID to PSM") if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then Error(PSMGenericClient_PSMGetLastErrorString()) EndIf   LogWrite("Terminating Dispatcher Utils Wrapper")   PSMGenericClient_Term()   Return $PSM_ERROR_SUCCESS   EndFunc       Func SiteLogIn() LogWrite("Starting SiteLogin funtion - Nirmal2") ; sleep(1000) WinActivate("vSphere Web Client - Google Chrome") send("{TAB}") ;send($TargetUsername) ClipPut(" ") sleep(2000) ClipPut($Username) sleep(200) Send("^v") sleep(500) ClipPut(" ") sleep(500) send("{TAB}") ;send($TargetPassword) sleep(500) ClipPut($Password) sleep(500) Send("^v") ClipPut(" ") sleep(500) send("{ENTER}")     ; BlockInput(0)     EndFunc     ; #FUNCTION# ==================================================================================================================== ; Name...........: Error ; Description ...: An exception handler - displays an error message and terminates the dispatcher ; Parameters ....: $ErrorMessage - Error message to display ; $Code - [Optional] Exit error code ; ===============================================================================================================================   Func Error($ErrorMessage, $Code = -1)   ; If the dispatcher utils DLL was already initialized, write an error log message and terminate the wrapper if (PSMGenericClient_IsInitialized()) Then LogWrite($ErrorMessage, True) PSMGenericClient_Term() EndIf   Local $MessageFlags = BitOr(0, 16, 262144) ; 0=OK button, 16=Stop-sign icon, 262144=MsgBox has top-most attribute set   MsgBox($MessageFlags, $ERROR_MESSAGE_TITLE, $ErrorMessage)   ; If the connection component was already invoked, terminate it if ($ConnectionClientPID <> 0) Then ProcessClose($ConnectionClientPID) $ConnectionClientPID = 0 EndIf   Exit $Code EndFunc   ; #FUNCTION# ==================================================================================================================== ; Name...........: LogWrite ; Description ...: Write a PSMWinSCPDispatcher log message to standard PSM log file ; Parameters ....: $sMessage - [IN] The message to write ; $LogLevel - [Optional] [IN] Defined if the message should be handled as an error message or as a trace messge ; Return values .: $PSM_ERROR_SUCCESS - Success, otherwise error - Use PSMGenericClient_PSMGetLastErrorString for details. ; =============================================================================================================================== Func LogWrite($sMessage, $LogLevel = $LOG_LEVEL_TRACE) Return PSMGenericClient_LogWrite($LOG_MESSAGE_PREFIX & $sMessage, $LogLevel) EndFunc   ; #FUNCTION# ==================================================================================================================== ; Name...........: PSMGenericClient_GetSessionProperty ; Description ...: Fetches properties required for the session ; Parameters ....: None ; Return values .: None ; =============================================================================================================================== Func FetchSessionProperties() ; CHANGE_ME   if (PSMGenericClient_GetSessionProperty("UserName", $Username) <> $PSM_ERROR_SUCCESS) Then Error("UserName paramter is missing") EndIf   if (PSMGenericClient_GetSessionProperty("Password", $Password) <> $PSM_ERROR_SUCCESS) Then Error("Password paramter is missing") EndIf   ; if (PSMGenericClient_GetSessionProperty("Address", $Address) <> $PSM_ERROR_SUCCESS) Then ; Error("Address paramter is missing") ;EndIf   EndFunc

8 REPLIES 8

L6 Presenter

Would it be possible for you post the error as well and why don't u give a try using PGU 1.3 for PSM web connectors?

L4 Transporter

Would it be possible for you post the error as well and why don't u give a try using PGU 1.3 for PSM web connectors?

L4 Transporter

Hi @Nirmalkumar Dhanaraj​ 

 

Does it in the background tries to run something that is blocked by the applocker on the PSM?

 

Also if you add a few logs messages, you can try to see where it fails, but also what succeeds.

 

Also, I use for IE an IESkelleton script. I don't know if you have access to that script? Since, if it IE I always use that, because it includes extra functions like hardening and stuff like that.

 

Kind regards,

Jelle

L2 Linker

Good day, Nirmal!

Perhaps, it would be better to turn on flash permanently in registry on specific URL and use web connector?

Hi @Gleb Smagin​ .. thanks for your email ..

 

I've done this via GPO exception (URL) and come up with a autoit script.

if you say it is possible via web connector, can you please share any screenshot or more details if possible?

Here is my connector for vCloud Director. It is using iFrame.

 

If you want to use webdriver for some reason it would be better to install webdriver libraries for autoit and code should be something like this(I'm using Chrome because IE crashes time to time 🙂 😞

#include "wd_core.au3"

#include "wd_helper.au3"

Local $sDesiredCapabilities, $sSession, $sButton

SetupChrome()

_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, $TargetAddress)

_ChromeSetInputValueByName($sSession,'username',$TargetUsername)

_ChromeSetInputValueByName($sSession,'password',$TargetPassword)

_WD_Shutdown()

Send("{ENTER}")

Func SetupChrome()

  _WD_Option('Driver', 'chromedriver.exe')

  _WD_Option('Port', 9515)

  $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & '] }}}}'

 EndFunc  ;==>SetupChrome

 Func _ChromeSetInputValueByName($sSession,$Name,$Value)

 $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='"&$name&"']")

 _WD_ElementAction($sSession,$sButton,'value', $Value)

EndFunc

 

 

Field_Content_versions_oct20__0682J000005iwdKQAQ.png

L4 Transporter

@Nirmalkumar Dhanaraj​  thanks for the code,

we have changed a custom code from for a VNC connector + few codes from You.

our scenario, we allowed the exception of unrecognized ssl certification, and add credentials. flash player is been allowed form registry .

but when we add it to the account and test, we getting a page to allow flash. right clicking the middle of the page.

if we manually try it in PSM server we don't get it. flash player enabled and it's connecting smoothly .

have you experienced this before ? have you able to add the Vsphere with flash ?

0682J0000070hTLQAY.jpg

L2 Linker

Hi Nirmal, Do you've a working Auto IT script for VMWARE flash web console login via PSM. If so, please can you share it.

We're also trying to deploy the same in our environment, but the one we developed is not standard and failing sometimes.

  • 1273 Views
  • 8 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!