Untitled
unknown
plain_text
a year ago
849 B
4
Indexable
# Get all devices on the domain $devices = Get-ADComputer -Filter * # Loop through each device foreach ($device in $devices) { $deviceName = $device.Name $loggedOnUser = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $device.Name | Select-Object -ExpandProperty UserName $mappedDrives = Get-WmiObject -Class Win32_MappedLogicalDisk -ComputerName $device.Name | Select-Object -Property DeviceID, ProviderName # Output device name, logged-on user, and mapped drives Write-Host "Device Name: $deviceName" Write-Host "Logged-On User: $loggedOnUser" Write-Host "Mapped Drives:" $mappedDrives | Format-Table -AutoSize Write-Host "----------------------------------------" # Check if 5 devices are already outputted if ($devices.IndexOf($device) -eq 4) { break } }
Editor is loading...
Leave a Comment