Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browse files on camera using PowerShell

Tags:

powershell

If I connect my digital camera via USB, Windows Explorer lists it under Computer as a device. I can browse it using Explorer, see folders, file properties etc, and copy/delete files.

This is all without setting the camera to be a storage device (in which case I believe the camera will show up as a flash drive, with an assigned drive letter, making this easy).

Is there a way for me to access and browse the files and folders on the camera using Windows PowerShell? As far as I can tell, no drive letter is (automatically) assigned to the device.

I'm not looking for workarounds - I can copy the files with explorer, not problem. I'm asking because I want to play around with PowerShell :-)

Thanks

UPDATE:

I've managed to get a Win32PnPEntity object of the camera using the following:

Get-WmiObject Win32_USBControllerDevice | ForEach-Object { $_; [Wmi]$_.Dependent }

Followed by Get-WmiObject win32_pnpentity -filter "name='Canon PowerShot A480'" using the name I got from the previous command (PNPDeviceID would probably be a better choice but the name was easier to type :P )

However, I don't know if I can do anything useful with that Win32PnPEntity object.

like image 424
Pieter Müller Avatar asked Mar 02 '12 10:03

Pieter Müller


People also ask

How do I access the camera in PowerShell?

How can I use Windows PowerShell to find a webcam or camera that is attached to my laptop? Use the Get-CimInstance or the Get-WmiObject cmdlet, examine the Win32_PnpEntity WMI class, and look for something that matches camera in the caption.

How do I search for a file in PowerShell?

Get-ChildItem cmdlet in PowerShell is used to get items in one or more specified locations. Using Get-ChildItem, you can find files. You can easily find files by name, and location, search file for string, or find file locations using a match pattern.

How do I get a list of files in PowerShell?

Like the Windows command line, Windows PowerShell can use the dir command to list files in the current directory. PowerShell can also use the ls and gci commands to list files in a different format.

How do I browse a folder in PowerShell?

Just type CD, followed by the folder name. If I were in the C:\Users folder and wanted to navigate to the Brien subfolder, I could type CD Brien.


1 Answers

You can combine information from the two following articles: https://devblogs.microsoft.com/powershell/get-usb-using-wmi-association-classes-in-powershell/

This will allow you to retrieve the device ID associated with your specific USB device (from the Name property, for example).

Then use WMI for accessing the files: How can I create a PowerShell script to copy a file to a USB flash drive?

like image 154
David Brabant Avatar answered Sep 28 '22 22:09

David Brabant