I am creating an automation script that should take a user's input for version, package new, and new package path, then compress it into a zip folder. Unfortunately, I can't hardcode the paths, so I'm struggling with how to use relative paths and user inputs that I have to validate before using.
$env = Read-Host -Prompt "Version Number"
if ($env.length -ne 7) {
$env = Read-Host "Re-enter version number"
}
$packageName = Read-Host -Prompt "Package Name"
$newPackage = Write-Output $packageName"."$env
$newDirectory = Read-Host -Prompt "Path to new directory"
$deployPath = Read-Host -Prompt "Path to Deploy.ps1 file"
$zipFile = Read-Host -Prompt "Path for new zip file"
$newItem = $newDirectory"/"$newPackage
Write-Host $newItem
new-item $newItem -type directory
Copy-Item $deployPath -Destination $zipFile
Microsoft.PowerShell.Archive\Compress-Archive -Path /Users/SG/projects/$newPackage -DestinationPath /Users/SG/$newPackage.zip
I need the $zipFile to be input from the user, and the -Path/-DestinationPath should be relative paths since they can't be hardcoded.