Tech Community Live: Endpoint Manager edition
Jul 21 2022, 08:00 AM - 12:00 PM (PDT)

Configure Local Admins on Intune Hybrid joined devices, per device

%3CLINGO-SUB%20id%3D%22lingo-sub-3315624%22%20slang%3D%22en-US%22%3EConfigure%20Local%20Admins%20on%20Intune%20Hybrid%20joined%20devices%2C%20per%20device%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3315624%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20looking%20for%20a%20way%20to%20manage%20local%20administrators%20on%20the%20Windows%20Endpoint%20devices.%20These%20devices%20are%20currently%20in%20a%20hybrid%20joined%20configuration.%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20a%20hand%20full%20of%20users%20that%20use%20VPN%20and%20a%20majority%20the%20don't%2C%20they%20consume%20online%20services.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThe%20original%20plan%20was%20to%20use%20AD%20groups%20one%20per%20machine%20and%20then%20where%20required%20assign%20user%20the%20user%20to%20the%20group%20for%20the%20target%20machine.%20In%20reality%20this%20only%20works%20reliable%20for%20users%20who%20are%20on%20site%20as%20the%20VPN%20causes%20issue%20with%20the%20user%20membership%20not%20being%20updated.%20The%20vpn%20is%20not%20running%20until%20after%20login.%20and%20obviously%20users%20who%20do%20not%20use%20the%20vpn%20will%20never%20be%20able%20to%20have%20the%20group%20added.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20been%20looking%20to%20see%20if%20I%20can%20use%20groups%20in%20AAD%2C%20but%20I'm%20not%20seeing%20any%20clear%20examples%20except%20for%20managing%20groups%20of%20machines.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20found%20that%20it%20can%20be%20done%20via%20policy%2C%20but%20I%20have%20my%20doubt%20about%20how%20good%20it%20may%20be%20to%20have%20hundreds%20of%20policies%20for%20this%20purpose.%26nbsp%3B%3C%2FP%3E%3CP%3EHas%20anyone%20else%20had%20experience%20solving%20this%20or%20similar%2C%20and%20can%20make%20suggestions%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3315624%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdministrator%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHybrid%20Configuration%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIntune%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Elocal%20account%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3342099%22%20slang%3D%22en-US%22%3ERe%3A%20Configure%20Local%20Admins%20on%20Intune%20Hybrid%20joined%20devices%2C%20per%20device%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3342099%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1381262%22%20target%3D%22_blank%22%3E%40clubbing80s%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Edid%20you%20already%20look%20at%20an%20always%20on%20vpn%20based%20on%20device%20authentication%3F%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EAnother%20option%20is%20setup%20an%20autopilot%20profile%20and%20make%20the%20user%20local%20admin%20during%20enrollment.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EAnd%20you%20can%20also%20create%20a%20PowerShell%20script%20that%20makes%20your%20user%20a%20local%20admin%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ekind%20regards%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Erene%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3354525%22%20slang%3D%22en-US%22%3ERe%3A%20Configure%20Local%20Admins%20on%20Intune%20Hybrid%20joined%20devices%2C%20per%20device%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3354525%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1010507%22%20target%3D%22_blank%22%3E%40Mr_Helaas%3C%2FA%3E%2C%3CBR%20%2F%3EThanks%20for%20that.%3CBR%20%2F%3E-%20Always%20on%20VPN%20is%20on%20the%20roadmap%2C%20distant%20horizon%2C%20years%20away.%3CBR%20%2F%3E-%20Going%20to%20be%20using%20AutoPilot%2C%20scheduled%20for%20later%20this%20year.%3CBR%20%2F%3E-%20with%20regard%20to%20using%20PowerShell%20I%20tried%20to%20add%20my%20user%20to%20my%20machines%20Local%20admins%20and%20the%20lookup%20for%20my%20azure%20UPN%20fails%20on%20the%20lookup.%20I%20have%20tried%20an%20number%20of%20different%20ways%20to%20do%20the%20lookup%20but%20all%20fail%2C%20I%20suspect%20this%20is%20because%20of%20the%20Hybrid%20domain%20join.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3355160%22%20slang%3D%22en-US%22%3ERe%3A%20Configure%20Local%20Admins%20on%20Intune%20Hybrid%20joined%20devices%2C%20per%20device%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3355160%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1381262%22%20target%3D%22_blank%22%3E%40clubbing80s%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20not%20a%20PowerShell%20expert%20but%20did%20you%20already%20try%20this%20method%20to%20get%20the%20logged%20in%20users%3F%20This%20scripts%20will%20create%20for%20every%20logged%20in%20user%20a%20firewall%20rule%20for%20teams.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESource%20%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fclient-firewall-script%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fclient-firewall-script%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20the%20below%20code%20is%20working%20you%20can%20change%20the%20script%20and%20replace%20the%20firewall%20rule%20to%20local%20admin.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24users%20%3D%20Get-ChildItem%20(Join-Path%20-Path%20%24env%3ASystemDrive%20-ChildPath%20'Users')%20-Exclude%20'Public'%2C%20'ADMINI~*'%0Aif%20(%24null%20-ne%20%24users)%20%7B%0A%20%20%20%20foreach%20(%24user%20in%20%24users)%20%7B%0A%20%20%20%20%20%20%20%20%24progPath%20%3D%20Join-Path%20-Path%20%24user.FullName%20-ChildPath%20%22AppData%5CLocal%5CMicrosoft%5CTeams%5CCurrent%5CTeams.exe%22%0A%20%20%20%20%20%20%20%20if%20(Test-Path%20%24progPath)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(-not%20(Get-NetFirewallApplicationFilter%20-Program%20%24progPath%20-ErrorAction%20SilentlyContinue))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24ruleName%20%3D%20%22Teams.exe%20for%20user%20%24(%24user.Name)%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22UDP%22%2C%20%22TCP%22%20%7C%20ForEach-Object%20%7B%20New-NetFirewallRule%20-DisplayName%20%24ruleName%20-Direction%20Inbound%20-Profile%20Domain%20-Program%20%24progPath%20-Action%20Allow%20-Protocol%20%24_%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Clear-Variable%20ruleName%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20Clear-Variable%20progPath%0A%20%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CBR%20%2F%3EAnother%20option%20is%20to%20implement%20autopilot%20earlier.%20This%20is%20the%20easiest%20method%20in%20my%20opinion.%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3CP%3EKind%20regards%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Erene%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi, 

I'm looking for a way to manage local administrators on the Windows Endpoint devices. These devices are currently in a hybrid joined configuration. 

We have a hand full of users that use VPN and a majority the don't, they consume online services. 

The original plan was to use AD groups one per machine and then where required assign user the user to the group for the target machine. In reality this only works reliable for users who are on site as the VPN causes issue with the user membership not being updated. The vpn is not running until after login. and obviously users who do not use the vpn will never be able to have the group added. 

I have been looking to see if I can use groups in AAD, but I'm not seeing any clear examples except for managing groups of machines. 

I have found that it can be done via policy, but I have my doubt about how good it may be to have hundreds of policies for this purpose. 

Has anyone else had experience solving this or similar, and can make suggestions ? 

Thanks

3 Replies

Hi @clubbing80s 

 

did you already look at an always on vpn based on device authentication? 

Another option is setup an autopilot profile and make the user local admin during enrollment. 

And you can also create a PowerShell script that makes your user a local admin 

 

kind regards,

 

rene 

 

@Mr_Helaas,
Thanks for that.
- Always on VPN is on the roadmap, distant horizon, years away.
- Going to be using AutoPilot, scheduled for later this year.
- with regard to using PowerShell I tried to add my user to my machines Local admins and the lookup for my azure UPN fails on the lookup. I have tried an number of different ways to do the lookup but all fail, I suspect this is because of the Hybrid domain join.

Hi @clubbing80s ,

 

I am not a PowerShell expert but did you already try this method to get the logged in users? This scripts will create for every logged in user a firewall rule for teams. 

 

Source : https://docs.microsoft.com/en-us/microsoftteams/client-firewall-script

 

If the below code is working you can change the script and replace the firewall rule to local admin. 

$users = Get-ChildItem (Join-Path -Path $env:SystemDrive -ChildPath 'Users') -Exclude 'Public', 'ADMINI~*'
if ($null -ne $users) {
    foreach ($user in $users) {
        $progPath = Join-Path -Path $user.FullName -ChildPath "AppData\Local\Microsoft\Teams\Current\Teams.exe"
        if (Test-Path $progPath) {
            if (-not (Get-NetFirewallApplicationFilter -Program $progPath -ErrorAction SilentlyContinue)) {
                $ruleName = "Teams.exe for user $($user.Name)"
                "UDP", "TCP" | ForEach-Object { New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Profile Domain -Program $progPath -Action Allow -Protocol $_ }
                Clear-Variable ruleName
            }
        }
        Clear-Variable progPath
    }
}


Another option is to implement autopilot earlier. This is the easiest method in my opinion.

   

Kind regards,

 

rene