Tag: Files

FilesStorage

Create Test Log Files

# Set number of days, in the past, to create log files for $days = 14 # Set directory to create logs in $directory = "C:\Test\Logs" $i=1 While($i -lt $days){ # Get Date and create log file $date = (Get-Date).AddDays(-$i) $logFile = "u_ex" + ($date.Year).ToString().Substring(2,2) + (($date.Month).ToString().PadLeft(2)).Replace(" ","0") + (($date.Day).ToString().PadLeft(2)).Replace(" ","0") + ".log" $logPath = join-path $directory $logFile $date |...
FilesStorage

Zip All Files in Folder

# Get the files to zip $FilesToZip = Get-ChildItem -Path $FolderPath -File # Load the assembly to get the zip functionality [Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" ) | Out-Null # Set compression level $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal # Set Zip file pathc based on folder $ZipPath = Join-Path $FolderPath "$(Split-Path $FolderPath -Leaf).zip" # initialize the zip file $Archive = [System.IO.Compression.ZipFile]::Open( $ZipPath, "Update" ) #...