I am writing a script to automate the backup of files to a USB flash memory. Not all memory sticks have the same drive ID. The script searches for a path to drives E:, F:, G: and H: and reports failure to find a drive if no flash drive is connected. If the flash drive is subsequently connected, the test still returns False.
Try this. Plug a USB memory stick, known to be drive E:, in and from the Powershell console test the path to E:. It returns True. Now remove the memory stick and test the path to drive E: and False is returned, as expected. Now plug the USB stick back in and repeat the test-path E: cmdlet and False is returned. Why?