User Profile
Harm_Veenstra
MVP
Joined 5 years ago
User Widgets
Recent Discussions
Re: Fetch Email of Login User In System Context
Ah, if devices are used by multiple users or are different from the enrollment user... Ok, I modified Andrew Taylor's script a bit to return the email address: function get-UserPrincipalNameFromLoggedOnUser() { <# .SYNOPSIS This function is used to find the logged-in user's userprincipalname as System .DESCRIPTION This function is used to find the logged-in user's userprincipalname as System .EXAMPLE getloggedindetails Returns the SID and Username in an array .NOTES NAME: getloggedindetails Written by: Andrew Taylor (https://andrewstaylor.com) and changed by Harm Veenstra to return only the User Principal Name #> ##Find logged in username $user = Get-WmiObject Win32_Process -Filter "Name='explorer.exe'" | ForEach-Object { $_.GetOwner() } | Select-Object -Unique -Expand User ##Find logged-in user's SID ##Loop through registry profile list until ProfileImagePath matches and return the path $path = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*" $sid = (Get-ItemProperty -Path $path | Where-Object { $_.ProfileImagePath -like "*$user" }).PSChildName try { $userprincipalname = (Get-ChildItem "Registry::HKEY_USERS\$($sid)\Software\Microsoft\Windows NT\CurrentVersion\WorkplaceJoin\AADNGC" -Recurse -ErrorAction Stop).GetValue('UserID') } catch { $userprincipalname = "Not found" } return $userprincipalname } Original source: https://andrewstaylor.com/2023/11/07/enumerating-the-logged-on-user-when-running-as-system-with-azure-ad-entra-joined-devices/16Views0likes0Comments- 51Views0likes0Comments
- 80Views0likes0Comments
Re: PowerShell scripts not delivering to Windows devices
If the installation fails but the script exits successfully (Exit 0), it will not attempt the installation again. But to troubleshoot, you can add Start-Transcript c:\windows\temp\log.txt to the top of the script and Stop-Transcript at the end of the script. Save and upload the modified script, it will rerun on the devices again, so you might want to limit this to the failing device, and check the log afterwards. You could also try adding the MSIX as a Line-of-Business-App in Windows Apps instead of using a script.91Views1like0CommentsRe: Can't add device member in Static Security Entra Group with powershell
This does work. New-MgGroupMember -GroupId XYZ -DirectoryObjectId (Get-MgDevice -Filter "displayName eq 'COMPUTERNAME' ").Id It queries using Graph for the device ID in the process using the display name of the device.69Views0likes0CommentsRe: Fetch Email of Login User In System Context
It's in the registry beneath the Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo key; you could query it using: (Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo -Recurse).GetValue('UserEmail')120Views1like0CommentsRe: .Net mail message, PowerShell and Microsoft Purview Infrmation Protection
https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users.actions/send-mgusermail?view=graph-powershell-1.0 Using Send-MgUsermail gives you more options to label emails. Have you checked that already?71Views0likes0CommentsRe: Intermittent issues with PowerShell MSteams command responses Since May 10, 2025
https://learn.microsoft.com/en-us/powershell/module/microsoftteams/set-cstenantfederationconfiguration?view=teams-ps#description Starting May 5, 2025, Skype Consumer Interoperability with Teams is no longer supported and the parameter AllowPublicUsers can no longer be used. I installed the latest version of the Module just now, 7.2.0, and I don't see those properties anymore57Views0likes0CommentsRe: Intermittent issues with PowerShell Command Responses Since May 10, 2025
https://learn.microsoft.com/en-us/powershell/module/microsoftteams/set-cstenantfederationconfiguration?view=teams-ps#description Starting May 5, 2025, Skype Consumer Interoperability with Teams is no longer supported and the parameter AllowPublicUsers can no longer be used. I installed the latest version of the Module just now, 7.2.0, and I don't see those properties anymore104Views0likes0CommentsRe: Architecture of PowerShell?
PowerShell is deeply integrated with .NET and relies on the .NET Common Language Runtime (CLR) for its execution. It leverages .NET objects for input and output, allowing for robust and flexible data handling. PowerShell also utilizes .NET libraries and classes to extend its functionality. Here's a more detailed breakdown: .NET Runtime Integration: PowerShell is built on the .NET CLR: This means PowerShell relies on the .NET runtime for its core functionality, enabling it to execute .NET code and utilize its libraries. .NET objects: PowerShell treats all inputs and outputs as .NET objects, allowing for seamless interaction with .NET types and methods. No text parsing: Because it uses .NET objects, PowerShell doesn't need to parse text output from commands, making it more efficient and reliable. .NET CLR and PowerShell: Core component: The .NET CLR is the virtual machine component of .NET that manages the execution of .NET programs. Just-in-time compilation: The CLR compiles managed code into machine instructions at runtime, allowing for platform-specific execution. Services: The CLR provides various services like memory management, garbage collection, and exception handling, which PowerShell benefits from. PowerShell Editions and .NET: Windows PowerShell: The original version of PowerShell, bundled with Windows, uses the full .NET Framework, which is Windows-specific. PowerShell: The cross-platform version of PowerShell (also known as PowerShell Core) is built on .NET Core (now simply referred to as .NET). .NET compatibility: The .NET runtime version dictates the compatibility of PowerShell with specific .NET APIs and modules. Extending PowerShell with .NET: Cmdlets: PowerShell cmdlets, the building blocks of PowerShell scripts, are often specialized .NET classes. .NET libraries: PowerShell can directly utilize .NET libraries and classes to perform various tasks, making it a powerful tool for system administration and automation. Dynamic types: PowerShell's extensible type system allows for creating dynamic types based on .NET types. In essence, PowerShell's power and flexibility stem from its deep integration with the .NET Framework and its ability to seamlessly leverage .NET's capabilities. This was a Google search with your question ;-) Powershell is built on .NET Framework; the current version is 8.0.x for version 7.5Views0likes0Comments
Recent Blog Articles
No content to show