Professional Documents
Culture Documents
Office 365 Subscription Info2
Office 365 Subscription Info2
{
param([string]$zipfilename)
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipfilename).IsReadOnly = $false
}
function Add-Zip{
param([string]$zipfilename)
Process {
if(-not (test-path($zipfilename)))
{
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" *
18))
(dir $zipfilename).IsReadOnly = $false
}
$zipPackage.CopyHere($_.FullName)
}
}
$date = (Get-date).Tostring('MM-dd-yyyy-HH-mm')
$server = $ENV:Computername
#Logging
$CheckLogPath = Test-Path E:\logs\archiving-logs\
if (-not($checklogpath))
{
New-item -type directory -path E:\logs\archiving-logs
}
$now = get-date
$LogOutput = @()
New-Zip \\iceopsnas\iceopsnas.grp\ice_logs\r5\Server_logs\$server\Sharepoint\
$date.zip
start-sleep -s 3
start-sleep -s 60
$LogOutput +=
"------------------------------------------------------------------------"
$LogOutput += "Following logs have been zipped and moved to NAS and located at
\\iceopsnas\iceopsnas.grp\ice_logs\r5\Server_logs\$server\Sharepoint\$date.zip"
$LogOutput += "`n"
}Else {
$LogOutput += "`n"
$LogOutput += "SOME ISSUE OCCURRED DURING LOGS ARCHIVING AS TOTAL NO OF FILES
TO BE ARCHIVED WERE $TOBEMOVED AND TOTAL NO OF FILES THAT HAS BEEN ARCHIVED IS
$MOVED. Below are the files that were not moved.`n"
$NotMoved = Compare -ReferenceObject $ListToBeMoved -DifferenceObject
$ListMoved | % {$_.InputObject}
$LogOutput += $NotMoved
$LogOutput += "`n"
$LogOutput += "Files that were not moved have not been deleted and is present
at E:\logs\source_logs and will moved at the next run."
}
$NotMoved | % {
$file = $_
dir E:\logs\source_logs\ | % {
$logfile = $_.name -replace ".log", ""
$logf = $_.name
If ($file -notlike "$logfile") {
remove-item E:\logs\source_logs\$logf
}
}