Many tasks we often perform manually can be automated. This saves time and also reduces the likelihood of errors.
One such task could be downloading the latest build of an application we are testing. In this article, we will look at how to easily (semi-)automatically download folders (not just) from a shared drive using PowerShell.
Imagine this scenario: We have a network drive or shared storage where the latest development versions of an application are automatically stored. If we want to test this version, we have to open Explorer, find the required folder, identify the latest version, and download it to our disk. It’s a simple operation, but it takes some time, and if we need to repeat it multiple times a day, efficiency drops significantly.
To write the script, basic PowerShell knowledge will suffice.
We get a list of folders, from which we will later create a “menu” and add information about the folder's creation date and time, as well as whether the folder has already been downloaded:
$downloadList += [pscustomobject]@{ Index = $downloadIndex; DateTime = $_.LastWriteTime.ToString("yyyy-MM-dd HH:mm"); Name = $_.Name; FullName = $_.FullName; IsDownloaded = $isDownloaded; }
Create the menu is done by displaying the list in a table format using Format-Table. Folder number to download is then prompted using Read-Host:
$downloadList | Format-Table -Property Index, DateTime, Name, IsDownloaded -AutoSize $PROMPT = Read-Host "Select a number of build to download"
This simple script is just an example that even straightforward operations are worth automating, and creating them doesn’t have to be complicated. I personally use a similar script several times a day (running them using Sekubu). After downloading, I can also immediately run the application installer.
Share article
Author
Jan ZatloukalTester and developer with a passion for automation and improving the development process. I am currently working on an electron microscope automation project in Python.
Get the latest updates from the world of Edhouse – news, events, and current software and hardware trends.
Thank you for your interest in subscribing to our newsletter! To complete your registration you need to confirm your subscription. We have just sent you a confirmation link to the email address you provided. Please click on this link to complete your registration. If you do not find the email, please check your spam or "Promotions" folder.