Bugfix
This commit is contained in:
parent
e94677fad5
commit
296df2695b
@ -1,14 +1,12 @@
|
|||||||
# 7zip_to_netapp_v2.ps1
|
# 7zip_to_netapp_v2.ps1
|
||||||
# Author: F. Bischof (frank@meer-web.nl)
|
# Author: F. Bischof (info@meer-web.nl)
|
||||||
# Version 2.5.0
|
# Version 2.6.0
|
||||||
|
|
||||||
# Set global vars
|
# Set global vars
|
||||||
$CSV = "C:\MyCSVFile.csv"
|
|
||||||
$LOGFILE = "C:\MyCSVFile.$TIMESTAMP.log"
|
|
||||||
|
|
||||||
# Set script vars
|
|
||||||
$TIMESTAMP = Get-Date -Format "yyyyMMddHHmm"
|
$TIMESTAMP = Get-Date -Format "yyyyMMddHHmm"
|
||||||
$TARGET_FILENAME = "${TIMESTAMP}-archive.7z"
|
$TARGET_FILENAME = "${TIMESTAMP}-archive.7z"
|
||||||
|
$CSVFILE = "C:\Scripts\movethis.csv"
|
||||||
|
$LOGFILE = "C:\Scripts\$TIMESTAMP.log"
|
||||||
|
|
||||||
# Writelog function
|
# Writelog function
|
||||||
if (!(test-path $LOGFILE)) {
|
if (!(test-path $LOGFILE)) {
|
||||||
@ -24,12 +22,11 @@ function WRITELOG {
|
|||||||
WRITELOG "=========================== Archiving started ==========================="
|
WRITELOG "=========================== Archiving started ==========================="
|
||||||
|
|
||||||
# Check if CSV file exists
|
# Check if CSV file exists
|
||||||
if (test-path $CSV) {
|
if (test-path $CSVFILE) {
|
||||||
WRITELOG "Loading CSV file $CSV"
|
WRITELOG "Loading CSV file $CSVFILE"
|
||||||
$CSVFILE = import-csv -Path "${CSV}"
|
|
||||||
} else {
|
} else {
|
||||||
WRITELOG "CSV file not found! ($CSV)"
|
WRITELOG "CSV file not found! ($CSVFILE)"
|
||||||
Write-Output "$CSV does not exists!"
|
Write-Output "$CSVFILE does not exists!"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +34,7 @@ if (test-path $CSV) {
|
|||||||
(Get-Content $CSVFILE | Select-Object -Skip 1) | Set-Content $CSVFILE ## Remove first line
|
(Get-Content $CSVFILE | Select-Object -Skip 1) | Set-Content $CSVFILE ## Remove first line
|
||||||
"FROM,TO`n" + (Get-Content $CSVFILE -Raw) | Set-Content $CSVFILE ## Add FROM,TO to CSV file
|
"FROM,TO`n" + (Get-Content $CSVFILE -Raw) | Set-Content $CSVFILE ## Add FROM,TO to CSV file
|
||||||
(Get-Content $CSVFILE) | Where-Object {$_.trim() -ne "" } | Set-Content $CSVFILE ## Remove empty lines
|
(Get-Content $CSVFILE) | Where-Object {$_.trim() -ne "" } | Set-Content $CSVFILE ## Remove empty lines
|
||||||
|
$CSVFILE = import-csv -Path ${CSVFILE}
|
||||||
|
|
||||||
# Create alias
|
# Create alias
|
||||||
set-alias 7z "$env:ProgramFiles\7-Zip\7z.exe"
|
set-alias 7z "$env:ProgramFiles\7-Zip\7z.exe"
|
||||||
|
Loading…
Reference in New Issue
Block a user