#region Set variables
$ArchiveFolder = "\\zusscgrcprodwebhelp.file.core.windows.net\webhelp\dev\~Archives\resources\"
$Logfile = "\\zusscgrcprodwebhelp.file.core.windows.net\webhelp\dev\~Archives\resources\Archives.log"
$resourcesDev = "\\zusscgrcprodwebhelp.file.core.windows.net\webhelp\dev\resources\"
$resourcesStg = "\\zusscgrcprodwebhelp.file.core.windows.net\webhelp\stg\resources\"
$resourcesExp = "\\zusscgrcprodwebhelp.file.core.windows.net\webhelp\tst-expere\resources\"
$resourcesTst = "\\zusscgrcprodwebhelp.file.core.windows.net\webhelp\tst\resources\"
$resourcesPrd = "\\zusscgrcprodwebhelp.file.core.windows.net\webhelp\prod\resources\"

$BaseFilenameDev = "resources_dev_"
$BaseFilenameStg = "resources_stg_"
$BaseFilenameExp = "resources_tst-expere_"
$BaseFilenameTst = "resources_tst_"
$BaseFilenamePrd = "resources_prod_"

$TodaysDate = Get-Date -Format "yyyy-MM-dd"

$compressDev = @{
    Path = $resourcesDev
    CompressionLevel = "Fastest"
    DestinationPath = $ArchiveFolder + $BaseFilenameDev + $TodaysDate + '.zip'
}
$compressStg = @{
    Path = $resourcesStg
    CompressionLevel = "Fastest"
    DestinationPath = $ArchiveFolder + $BaseFilenameStg + $TodaysDate + '.zip'
}
$compressExp = @{
    Path = $resourcesExp
    CompressionLevel = "Fastest"
    DestinationPath = $ArchiveFolder + $BaseFilenameExp + $TodaysDate + '.zip'
}
$compressTst = @{
    Path = $resourcesTst
    CompressionLevel = "Fastest"
    DestinationPath = $ArchiveFolder + $BaseFilenameTst + $TodaysDate + '.zip'
}
$compressPrd = @{
    Path = $resourcesPrd
    CompressionLevel = "Fastest"
    DestinationPath = $ArchiveFolder + $BaseFilenamePrd + $TodaysDate + '.zip'
}
#endregion

#region Run compression commands and email
WriteLog("Archive server resources process begun.")
Compress-Archive @compressDev
WriteLog("Dev resources archived.")
Compress-Archive @compressStg
WriteLog("Stg resources archived.")
Compress-Archive @compressExp
WriteLog("Exp resources archived.")
Compress-Archive @compressTst
WriteLog("Tst resources archived.")
Compress-Archive @compressPrd
WriteLog("Prd resources archived.")
WriteLog("All server resources archived.")

#endregion

function WriteLog ($LogString)
{
    $DateTime = "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
    $LogMessage = "$Datetime $LogString"
    Add-content $LogFile -value $LogMessage
}