login script - grabbing network drive filesystem

I am trying to run a logon script to capture the logged on user network drive map file system. I run the command locally on computer and it works fine. I get the computername and file system of network drive.

if i run it as a login script I get the computer name but never the file system. I have even tried to put a start-sleep for 2 minutes. I still do not get it.

I am not sure what i am doing wrong

     $system= Get-WmiObject Win32_ComputerSystem -ComputerName localhost| Select-Object Name 
     $localdisk=Get-WMIObject Win32_Logicaldisk -filter "deviceid='M:'"  -ComputerName localhost


     $Object = New-Object PSObject -Property @{
ComputerName           = $system.Name
'M drive'              = $localdisk.FileSystem
}



$Object | Export-Csv -NoTypeInformation  \\networkdrivelocation\"$env:computername".csv

You may be able to fix this with a pretty simple change. Right now you’re using the Win32_LogicalDisk class for Get-WMIObject, where you may need to be using the Win32_MappedLogicalDisk class. I would change your code to look like the following and it should work at that point

     $system= Get-WmiObject Win32_ComputerSystem -ComputerName localhost| Select-Object Name 
     $localdisk=Get-WMIObject Win32_MappedLogicaldisk -filter "deviceid='M:'"  -ComputerName localhost


     $Object = New-Object PSObject -Property @{
ComputerName           = $system.Name
'M drive'              = $localdisk.FileSystem
}



$Object | Export-Csv -NoTypeInformation  \\networkdrivelocation\"$env:computername".csv

Bryce,

That did not work. I am beginning to think it is because of UAC on other computer.