[Request] Creating an install script. Need to check AD from an end-client machine.

As the title says, I’m looking to run a script that detects which OU an employee is part of, and then run a MSI file off of that. We don’t want this installed on every computer so we prefer not to use Group Policy for the install. Will also Take suggestions if this isn’t the best way to set up the AD check.

Issue: Because this is installing a program on a client-machine, AD isn’t enabled in the windows features. How would I best get the employee’s location to run the script?

Note: The Write-Host is only there for my testing.

$username = Read-Host prompt "Enter username" $user = Get-ADUser -Identity $username -Properties Canonicalname # Check User's Location if($user.DistinguishedName -like "*State 1*") { Write-Host "State 1" } elseif($user.DistinguishedName -like "*State 2*") { Write-Host "State 2" } elseif($user.DistinguishedName -like "*State 3*") { Write-Host "State 3" } elseif($user.DistinguishedName -like "*State 4*") { Write-Host "State 4" } elseif($user.DistinguishedName -like "*State 5*") { Write-Host "State 5" } elseif($user.DistinguishedName -like "*State 6*") { Write-Host "State 6" } else { Write-Host "Cannot determine user's location. Please install manually" } 

submitted by /u/mrmcweird
[link] [comments]

Leave a Reply