Did a quick search to see if someone’s posted on this before, but don’t see anything.
I’m running my PSADT via MECM, so as SYSTEM user. What’s the simplest method to check if the logged in user has a J:\ drive mapped?
Did a quick search to see if someone’s posted on this before, but don’t see anything.
I’m running my PSADT via MECM, so as SYSTEM user. What’s the simplest method to check if the logged in user has a J:\ drive mapped?
So here’s what I’ve come up with so far, the problem being that none of our computers will have the RSAT tools installed so the “Get-ADUser” fails…
#Check if logged on user has a j: drive to scan
$SID = (get-ADuser $CurrentLoggedOnUserSession.UserName).SID.Value
if (Test-Path "Registry::HKU\$SID\Network\j") {
#DO THE NEEDFULL
}
inside AppDeployToolkitMain.ps1, PSADT creates an object called $LoggedOnUserSessions
of ALL logged-on users.
If one of those users is active ($_.IsActiveUserSession =$true
) it creates $RunAsActiveUser
$RunAsActiveUser.SID
might be the SID of the current user you need.
Thanks Annoying, I was close… You’re the forum MVP again!
Here’s my finished code:
$driveLetter ="j"
$SID = $RunAsActiveUser.SID
$ActiveUserName = $RunAsActiveUser.UserName
if (Test-Path "Registry::HKU\$SID\Network\$driveLetter") {
#DO THE NEEDFUL
Write-Log -Message "Found ${driveLetter}: drive mapping for $ActiveUserName"
}
else {
Write-Log -Message "No ${driveLetter}: drive mapping found for $ActiveUserName"
}
I appreciate the recognition but I love the fact that you shared your solution for all to see.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.