login script - grabbing network drive filesystem

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of matthew moore matthew moore 2 months ago.

  • Author
    Posts
  • #68769
    Profile photo of matthew moore
    matthew moore
    Participant

    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
    
    
  • #68793
    Profile photo of Bryce McDonald
    Bryce McDonald
    Participant

    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
    
  • #68911
    Profile photo of matthew moore
    matthew moore
    Participant

    Bryce,

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

You must be logged in to reply to this topic.