Forum Discussion
_OSD_
Nov 26, 2020Copper Contributor
PowerShell to find and copy a file with wildcard
Hi, I need to copy a file which is located under a dynamically created subdirectory. Directory: C:\Users\StandardUser\AppData\Roaming\Mozilla\Firefox\Profiles\dynamically-created-directory\myDesire...
farismalaeb
Dec 01, 2020Steel Contributor
Hi
You can use the following command
You can use Join-Path to build the path and include the random folder
$x=join-path ('C:\Users\Faris\AppData\Roaming\Mozilla\Firefox\Profiles') -ChildPath (Get-childItem -Path 'C:\Users\Faris\AppData\Roaming\Mozilla\Firefox\Profiles')[0]
Please note that this will fetch the first directory, if there are multiple directories then you need to build small criteria to define which one to retrieve.
------------
If this answer helped, please click on Best Response and also a Like