You will first need to set up your server to enable Cross play following this guide
After you have enabled cross-play, open the Web console in the server's control panel.
Join the server and then look in the web console for the log of your joining.
You are looking for a line similar to this that contains your XboxID
01/19/2023 16:28:17: PlayFab socket with remote ID playfab/63B203A7D9581654 received local Platform ID Xbox_2433224801742044
Copy your XboxID from the webconsole, i.e. Xbox_XXXXXXXXXXXXXXXX
Click the Stop button in your server's control panel.
Click on the Configuration Files icon
Look for the Adminnlist.txt and open the file using the Text Editor
Paste your XboxID on a new line and then press the save button.
Start the server backup.
To use admin in game, you need to launch your game with the -console flag enabled.
-Navigate to where the game is installed on your PC, by default it should be C:\XboxGames\Valheim\Content\
-Find the valheim.exe file
-Right-click on the file and click the Create Shortcut option.
-Right-click on the shortcut and click on Properties
-Go to the Shortcut tab
-Find the Target option
-Add -console to the end. Make sure there is a space between valheim.exe and -console
-Click the Okay button to apply the changes
-Launch the game using the shortcut. To open the console, press F5