I have this batch file that look for the process name msmdsrv.exe, get the PID number using tasklist then get the port number using netstat where the connection type is established.
At the end it will export the result into a file PBD_Port.csv
for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq msmdsrv.exe" /fo csv') do (
set var=%%F
)
for /f "tokens=2 delims= " %%h in ('netstat -ano ^| findstr ESTABLISHED ^| findstr %var%') do (
set var1=%%h
)
echo %var1% > PBD_Port.csv
I use this code to get the port number of the PowerBi Desktop, as it do change every time when we launch Power Bi Desktop.
Is it possible to have a macro in Excel that do the same thing ? so instead of using a batch file where the user has to click on it, i want a macro to give the same result and write the result not in a CSV but in a worksheet.
edit : i built the code for the batch, I wanted a general advice how to translate this to VBA, thanks for your comment
edit : actually, i was over complicating things, the port number is already stored in a temporary text file generated by the new SSAS instance, see different solution here
http://community.powerbi.com/t5/Desktop/connect-to-powerbi-desktop/td-p/87310