Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
hi all,
is there anyway except DAX to getting logged in user name to windows on the pc that running the report
as DAX functions username() and userprincipalname() return the domain user name that loggen in to the report itself.
i've tried R script but it making proplems as it works with personal gateway and i already have enterprise gateway to SQL
and can't be solved (still waiting for microsoft to solve) this issue raised here https://community.fabric.microsoft.com/t5/Desktop/Failed-to-use-the-selected-gateway-Please-make-sur...
Hi,@tanehome1
I am glad to help you.
According to your description, are you trying to get the username of the account currently accessing the report?
You have tried to use username and UserPrincipalName functions to get the username, but it only shows the domain user of the current PC.
First of all I want to clarify that this is normal
These two functions return different results in different situations:
1. in power bi desktop: both functions return the current domain\user.
2. In power bi service: username() and userprincipalname() will show the name of the power bi user who is currently accessing the report (in a format similar to email).
In Power BI desktop:
In Power BI Service
Once you publish the report to the service, you should be able to see the current user's account information depending on who is logged in.
If you want to get the account information of the user accessing the report in another way, you could try to read the following official document.
Reports - Get Report - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Regarding your personal gateway connection with self-built R scripts that fails to connect
First of all enterprise gateway doesn't support R languages, while personal gateway does!
I'm sorry that I can't reproduce your problem directly, I'll give a few possible reasons below.
1. The data source required for Report is not consistent with the configured R script personal gateway data source?
Did you change the address of the local connector when connecting to the personal gateway connection?
If you have configured the Personal Gateway for R Scripts in a report, but the actual data source does not match the data source required for the report, you may have problems selecting the Personal Gateway connection on Service. Make sure that the data source is the same as the data source required for the report.
2.Is there a problem with the scripting?
For example, the corresponding data source configuration item in the R script used may be incorrect.
3.Is the version of the R script up to date?
Ensure that you use the Application are kept a new version (personal gateway and R script app).
4.Check to see if the account you are logged into on your power BI service is the same as the account you are logged into on desktop, gateway (personal mode) (because if you are an administrator, you can also manage other users' personal gateway connections)Make sure you are logged into the same account.
5. View the gateway logs in the app, by opening Additional logging to view the corresponding log report
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi v-jtian-msft
Thanks for your reply.
Yes, I’m trying to get the username of the account currently accessing the report as it’s published publically
Actually, I’ve tried the both functions of DAX after published the report via public URL and it show the user that I’ve used to login in to the power bi (free E5 developer account)
Also I’ve tried the SQL and it retrieving the user that has been used for the connection
I’ve read the send document regarding the API but I didn’t got how to use it as I’m a bigginer in power bi, I’m trying to find another way such as API or JSON that can retrieve usernames but didn’t got how to use
as i've found this code "(Get-CimInstance -ClassName Win32_ComputerSystem).Username" for API but can't find how and where to use.
Regarding, the gateway finally Microsoft has replied my ticket as this option not available now and may be added next releases (reply below)
(We informed you that, according to the below documentation, R and Python scripts only work with the personal mode gateway. However, in the personal mode gateway, we cannot refresh two data sources simultaneously. You asked if it is possible to use the enterprise gateway for the R script, but unfortunately, it is not supported. We provided you with an idea forum where you can raise this suggestion.)
Thanks Again.
I did search on and found that SQL script but it giving below error, is there any mistake I did?
DECLARE @CMD VARCHAR(500) =
(SELECT TOP 1 'tasklist /S ' + client_net_address +
' /FI "PID eq ' + CONVERT(VARCHAR(MAX),host_process_id) +
'" /V /FO LIST /U DOMAIN\Admin /P password'
FROM sys.dm_exec_connections C JOIN sys.dm_exec_sessions S
ON C.session_id = S.session_id WHERE S.session_id = @@SPID)
EXEC xp_cmdshell @CMD
Error:
output The system cannot find the file specified.
NULL
Hi,@tanehome1 .
It is possible that this problem occurs after you query the Sql script because there is an error in the path of the file formulated in your SQL script (i.e., your SQL script may have been written incorrectly), and therefore the formulated file cannot be found, so please check your SQL script.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.