Mapped drives are the shares on remote computers for which you assigned a drive letter for easier access. We can query these drives and the target shares behind them with a simple and easy powershell one liner.
Here is the tip of the day. Happy Learning.
Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName
Comments on this entry are closed.
This is exactly what I needed in a pinch. Thanks for posting
Try this for Remote computers
$computername = Get-Content ‘I:\NodeList\SNL.txt’
$CSVpath = “C:\MSI\Mps.csv”
remove-item $CSVpath
$Report = @()
foreach ($computer in $computername) {
Write-host $computer
$colDrives = Get-WmiObject Win32_MappedLogicalDisk -ComputerName $computer
foreach ($objDrive in $colDrives) {
# For each mapped drive – build a hash containing information
$hash = @{
ComputerName = $computer
MappedLocation = $objDrive.ProviderName
DriveLetter = $objDrive.DeviceId
}
# Add the hash to a new object
$objDriveInfo = new-object PSObject -Property $hash
# Store our new object within the report array
$Report += $objDriveInfo
}
# Export our report array to CSV and store as our dynamic file name
$Report | Export-Csv -NoType $CSVpath #$filenamestring
}
Nathan,
Thanks for sharing the code. How sure are you that it works?
Mapped drives are specific to user login. You are referring to some other mappings here like drives mapped to folders?
Nathan,
Thanks for the code. I am having trouble getting it to run on workstations where I need it to run remotely. It will run well on any and all servers but not on any workstations. I am not sure why or what dependency is causing this. If I run the command on the workstation (Get-WmiObject Win32_MappedLogicalDisk -ComputerName Win10) it works as defined. Any clues?
Michael
Hi , it look like working
Thanks
How about getting a list of shared drives for a specific user? I know the username I just need to know the shared drives they have access to?