-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get-LoggedOnUser broken within Windows Sandbox due to truncated ComputerName environment variable #947
Labels
Type: Issue / Bug
Something isn't working as expected
Comments
don't work with the 3.10.1 too, but you can fix/workaround it with you change |
@AlkHacNar, does |
Thanks mate, that's actually really good to know. |
just tested (Get-WmiObject win32_computersystem).DNSHostName as @obuolinis mentioned and it works too in the sandbox |
DanGough
added a commit
that referenced
this issue
Jul 29, 2024
…HostName() instead of $env:ComputerName -Fixes #947 (Windows Sandbox)
10 tasks
sintaxasn
pushed a commit
that referenced
this issue
Jul 30, 2024
…HostName() instead of $env:ComputerName -Fixes #947 (Windows Sandbox)
mjr4077au
pushed a commit
that referenced
this issue
Aug 12, 2024
…HostName() instead of $env:ComputerName -Fixes #947 (Windows Sandbox)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When run from within Windows Sandbox Get-LoggedOnUser fails with the following error message:
Exception calling "GetUserSessionInfo" with "1" argument(s): "The operation completed successfully"
To Reproduce
Steps to reproduce the behavior:
Toolkit Version:
Tested with 3.9.3
Powershell Version:
5.1
Additional context
This has been bugging me for quite some time already since I really love using Windows Sandbox as my PSADT package testing environment.
According to my investigation this is related to both Windows and Windows Sandbox design. The root cause is that Get-LoggedOnUser is calling GetUserSessionInfo CS function using Windows environment variable ComputerName as the name of the host:
PSAppDeployToolkit/Toolkit/AppDeployToolkit/AppDeployToolkitMain.ps1
Line 15811 in d04eda2
An actual computer name within Sandbox is a random GUID whereas ComputerName variable truncates it to 15 chars which is what breaks the function.
Fix Suggestion
This could possibly be a rather simple fix - you could be calling GetUserSessionInfo using DNSHostName property value of WMI class Win32_ComputerSystem rather than an environment variable. This property holds a full non-truncated computer name.
I'm not aware of any potential repercussions.
The text was updated successfully, but these errors were encountered: