It's been a little while since I've touched PowerShell so struggling to get this working as I expect.
$computerlist = Get-Content H:\MappedDrive\ListOfMachines.txt
ForEach ($computer in $computerlist)
{
$Result1 Get-WmiObject Win32_MappedLogicalDisk -computerName $computer | Select Name,ProviderName
$Result2 get-wmiobject win32_computersystem -computer $computer | select username
}
$Result += $Result1, $Result2 | Out-File H:\MappedDrive\$computer.txt
So I'm expecting to have it pull both the drive letter, location and username then output the computername as a text file. I've read lots of other forums but just cannot get both the Get-WmiObjects to work together.
Apologies if this is in the wrong forum was unsure which would be best.
Thanks