I have Powershell code like this:
$disks = Get-WmiObject -Class Win32_MappedLogicalDisk -Filter "DeviceID='Z:'"
foreach($disk in $disks)
{
[Console]::WriteLine("Object: " + $disk.Name + " is " + $disk.ProviderName );
}
But it selects objects outside of the current session, like other users on the terminal session. How can I limit this to objects only under the current session?
You can use this:
the where condition it’s only to be sure is a network drive and not other kind of unit.
You can read here other drivetype code