Search code examples
powershellwindows-phone-8

Open command prompt to access folders of a USB connected windows phone


I am trying to open a command prompt to access folders of a USB connected windows phone. I have tried several commands like the following but to no avail.

wmic logicaldisk get name

GET-WMIOBJECT win32_diskdrive | Where { $_.InterfaceType -eq 'USB' }

Could someone suggest me the best way to accomplish this without using any tool? My task is to access the mobile device to adjust language settings using PowerShell commands.

Phone : Lumia 1020 running Windows Phone 8.


Solution

  • To get a list of USB drives attached to the PC, execute this command.

    Get-WmiObject Win32_Volume -Filter "DriveType='2'"
    

    If your mobile is attached as a USB disk, it should show up. From the data you get back, you should be able to extract things like Caption, Label, Name and DriveLetter. Then you can automate things a little bit further:

    cd (Get-WmiObject Win32_Volume -Filter "DriveType='2'" | Where-Object label -eq "YourDiskName").DriveLetter
    

    EDIT: Since Get-WmiObject command is now depreciated, the preferred way is now to use Get-CimInstance.

     Get-CimInstance -Query "SELECT * FROM Win32_LogicalDisk WHERE DriveType=2"