Mapped drives for all users in Domain

Hey Everyone,

I am looking to get a list of all of our users and their mapped network drives.
So far I have a script to get my network drives. Any thoughts?

Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName

You of course have to run that command line on each computer in your AD environment
With PowerShell Remoteing enabled and if you have admin privileges to the hosts. You can just do.

( Get-ADComputer -Filter * ).Name `
| % { Invoke-Command -ComputerName $_ `
-ScriptBlock { Get-WmiObject -Class Win32_MappedLogicalDisk `
| select Name, ProviderName }}

Or something like…

Function Get-RemoteHostMappedDrives
param (
[Parameter(Mandatory=$true, HelpMessage=“Specify the Get-ADComputer name filter to apply (Use * for wildcard”)]
[string] $TargetHost

"Showing mapped on $TargetHost"

$Mapped = Get-WmiObject -class "Win32_MappedLogicalDisk" `
-namespace "root\CIMV2" `
-computername $TargetHost `
| Select DeviceID,ProviderName

ForEach ($drive in $mapped)
{ $drive.DeviceID, $drive.ProviderName }


Get-RemoteHostMappedDrives -TargetHost *

Hmmm … if I’m not wrong that wouldn’t work as you probably expect it. You have to run this commands in the context of logged on user. If you do it with Powershell remoting you would only get the mapped drives of the account you use to access the clients.

try something like this

$ComputerName = “computername”

gwmi win32_mappedlogicaldisk -ComputerName $ComputerName | select SystemName,Name,ProviderName,SessionID | foreach {
$disk = $_
$user = gwmi Win32_LoggedOnUser -ComputerName $ComputerName | where { ($.Dependent.split(“=”)[-1] -replace ‘"’) -eq $disk.SessionID} | foreach {$.Antecedent.split(“=”)[-1] -replace ‘"’}
$disk | select Name,ProviderName,@{n=“MappedTo”;e={$user} }