Compare commits
2
Commits
5b6fd565b9
...
d461fc7e2c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d461fc7e2c | ||
|
|
4e2065b6bb |
@@ -539,9 +539,13 @@ function Remove-File ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Function to ZIP a file or directory
|
# Function to ZIP a file or directory
|
||||||
function Zip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
function Zip-Object {
|
||||||
|
param(
|
||||||
|
[Parameter(ValueFromPipeline=$true)][string]$path,
|
||||||
|
[Parameter(ValueFromPipeline=$false)][string]$dest
|
||||||
|
)
|
||||||
If ( $(Get-Item $path) -is [System.IO.DirectoryInfo] ) {
|
If ( $(Get-Item $path) -is [System.IO.DirectoryInfo] ) {
|
||||||
$dest = '{0}\{1}.zip' -f $(Split-Path -Parent $path),$(Split-Path -Leaf $path)
|
If ( [string]::IsNullOrEmpty($dest) ) { $dest = '{0}\{1}.zip' -f $(Split-Path -Parent $path),$(Split-Path -Leaf $path) }
|
||||||
LogMsg "Creating zip file of: ${path}"
|
LogMsg "Creating zip file of: ${path}"
|
||||||
Try {
|
Try {
|
||||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||||
@@ -566,10 +570,9 @@ function Zip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
|||||||
|
|
||||||
# Function to UNZIP a file or directory
|
# Function to UNZIP a file or directory
|
||||||
function Unzip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
function Unzip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||||
$ext = [System.IO.Path]::GetExtension($path)
|
If ( [System.IO.Path]::GetExtension($path) -eq ".zip" ) {
|
||||||
If ( $ext -eq ".zip" ) {
|
|
||||||
LogMsg "Extracting ""${path}"" to ""${dest}"""
|
|
||||||
$dest = Split-Path -Parent $path
|
$dest = Split-Path -Parent $path
|
||||||
|
LogMsg "Extracting ""${path}"" to ""${dest}"""
|
||||||
Try {
|
Try {
|
||||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||||
[IO.Compression.ZipFile]::ExtractToDirectory($path, $dest)
|
[IO.Compression.ZipFile]::ExtractToDirectory($path, $dest)
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
. 'C:\Users\dyoder\Documents\Emberkom\Data\Projects\development\management-scripts\Tools.ps1'
|
||||||
|
## Make sure we have an administrative token
|
||||||
|
If ( IsAdmin )
|
||||||
|
{
|
||||||
|
$URL = 'https://lfupdate.s3.amazonaws.com/clients/windows_cli/LiquidFilesCLI-2.0.128.zip'
|
||||||
|
|
||||||
|
## Filename we'll download to
|
||||||
|
$FILENAME = Split-Path -Leaf $URL
|
||||||
|
|
||||||
|
## Full path for the downloaded zip file
|
||||||
|
$ZIP = "${Global:ToolsDirectory}\${FILENAME}"
|
||||||
|
|
||||||
|
## Once we extract the zip file, this will be the exe name inside
|
||||||
|
$EXE = '{0}.exe' -f [System.IO.Path]::GetFileNameWithoutExtension($FILENAME)
|
||||||
|
|
||||||
|
## Delete the zip file if it already exists
|
||||||
|
If ( Test-Path $ZIP ) {
|
||||||
|
LogMsg "Deleting existing file: ${ZIP}"
|
||||||
|
Try { Remove-Item $ZIP -Force }
|
||||||
|
Catch { LogErr $_.Exception.Message }
|
||||||
|
}
|
||||||
|
|
||||||
|
## Delete the exe file if it already exists
|
||||||
|
If ( Test-Path $EXE ) {
|
||||||
|
LogMsg "Deleting existing file: ${EXE}"
|
||||||
|
Try { Remove-Item $EXE -Force }
|
||||||
|
Catch { LogErr $_.Exception.Message }
|
||||||
|
}
|
||||||
|
|
||||||
|
## Download and unzip LiquidFiles CLI utility
|
||||||
|
Download-File -URL $URL -File $ZIP
|
||||||
|
Unzip-Object $ZIP
|
||||||
|
|
||||||
|
## Set the properties for the message
|
||||||
|
$From = $Env:COMPUTERNAME
|
||||||
|
$Subject = [System.IO.Path]::GetFileNameWithoutExtension($ZIP)
|
||||||
|
$Message = ""
|
||||||
|
|
||||||
|
## Create the path to $FileToUpload and zip the specified directory if necessary
|
||||||
|
If ( $(Get-Item $DataToUpload) -is [System.IO.DirectoryInfo] ) {
|
||||||
|
$FileToUpload = '{0}\{1}.zip' -f $Global:OutputDirectory,$(Split-Path -Leaf $path)
|
||||||
|
Zip-Object -path $DataToUpload -dest $FileToUpload
|
||||||
|
}
|
||||||
|
Else { $FileToUpload = $DataToUpload }
|
||||||
|
|
||||||
|
If ( Test-Path $FileToUpload ) {
|
||||||
|
LogMsg "Uploading ""${FileToUpload}"""
|
||||||
|
Try { Start-Process "${EXE}" -ArgumentList "filedrop /url:xfer.emberkom.net /from:""${From}"" /subject:""${Subject}"" /msg:""${Message}"" /c:n /deleteAfterUpload /f:""${ZIP}""" -Wait }
|
||||||
|
Catch { LogErr $_.Exception.Message }
|
||||||
|
}
|
||||||
|
Else { LogMsg "The specified file does not exist: ""${FileToUpload}""" }
|
||||||
|
|
||||||
|
}
|
||||||
|
Else { LogMsg "Must be an administrator to upload files" }
|
||||||
Reference in New Issue
Block a user