2023-11-19 17:42:22
This commit is contained in:
parent
bb36096e37
commit
8e6c50cf4c
|
@ -1,9 +1,9 @@
|
|||
$ModuleManifest = (Get-ChildItem -Path $PSScriptRoot | Where-Object {$_.Extension -eq '.psd1'})
|
||||
$ModuleManifest = (Get-ChildItem -Path $PSScriptRoot | Where-Object { $_.Extension -eq '.psd1' })
|
||||
$CurrentManifest = (Test-ModuleManifest $ModuleManifest)
|
||||
|
||||
$Aliases = @()
|
||||
$PrivateFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Private') | Where-Object {$_.Extension -eq '.ps1'})
|
||||
$PublicFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') | Where-Object {$_.Extension -eq '.ps1'})
|
||||
$PrivateFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Private') | Where-Object { $_.Extension -eq '.ps1' })
|
||||
$PublicFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') | Where-Object { $_.Extension -eq '.ps1' })
|
||||
|
||||
(@($PrivateFunctions) + @($PublicFunctions)) | ForEach-Object {
|
||||
try {
|
||||
|
@ -25,10 +25,10 @@ $PublicFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') | Whe
|
|||
}
|
||||
}
|
||||
|
||||
$FunctionsAdded = ($PublicFunctions | Where-Object {$_.BaseName -notin $CurrentManifest.ExportedFunctions.Keys})
|
||||
$FunctionsRemoved = ($CurrentManifest.ExportedFunctions.Keys | Where-Object {$_ -notin $PublicFunctions.BaseName})
|
||||
$AliasesAdded = ($Aliases | Where-Object {$_ -notin $CurrentManifest.ExportedAliases.Keys})
|
||||
$AliasesRemoved = ($CurrentManifest.ExportedAliases.Keys | Where-Object {$_ -notin $Aliases})
|
||||
$FunctionsAdded = ($PublicFunctions | Where-Object { $_.BaseName -notin $CurrentManifest.ExportedFunctions.Keys })
|
||||
$FunctionsRemoved = ($CurrentManifest.ExportedFunctions.Keys | Where-Object { $_ -notin $PublicFunctions.BaseName })
|
||||
$AliasesAdded = ($Aliases | Where-Object { $_ -notin $CurrentManifest.ExportedAliases.Keys })
|
||||
$AliasesRemoved = ($CurrentManifest.ExportedAliases.Keys | Where-Object { $_ -notin $Aliases })
|
||||
|
||||
if ($FunctionsAdded -or $FunctionsRemoved -or $AliasesAdded -or $AliasesRemoved) {
|
||||
try {
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
function Compress-VaultData() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Compressing data.
|
||||
|
||||
.DESCRIPTION
|
||||
Compressing the Vault data with compression level 9.
|
||||
#>
|
||||
|
||||
param(
|
||||
[Alias('P')][string]$Path,
|
||||
[Alias('N')][string]$Name,
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
function Start-VaultMoveFiles() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Moving files.
|
||||
|
||||
.DESCRIPTION
|
||||
Moving files from the Source to the Vault.
|
||||
#>
|
||||
|
||||
param(
|
||||
[string]$Mode,
|
||||
[string]$Source,
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
function Start-VaultRemoveDirs() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Removing directories.
|
||||
|
||||
.DESCRIPTION
|
||||
Removing empty directories in the Source.
|
||||
#>
|
||||
|
||||
param(
|
||||
[string]$Source,
|
||||
[long]$CreationTime,
|
||||
|
|
|
@ -1,34 +1,74 @@
|
|||
function Start-Vault {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
PowerShell Vault.
|
||||
|
||||
.DESCRIPTION
|
||||
The module moves files to Vault based on various criteria.
|
||||
|
||||
.PARAMETER Mode
|
||||
Script operation mode:
|
||||
'CP' | Coping data from the Source.
|
||||
'MV' | Moving data from the Source.
|
||||
'RM' | Only removing data from the Source.
|
||||
Default: 'MV'.
|
||||
|
||||
.PARAMETER Source
|
||||
Path to the source. E.g.: 'C:\Source'.
|
||||
|
||||
.PARAMETER Vault
|
||||
Path to the Vault. E.g.: 'D:\Vault'.
|
||||
|
||||
.PARAMETER CreationTime
|
||||
Time since file creation (in seconds). E.g.: '5270400'.
|
||||
If the time since file creation is greater than the specified value, they will be processed by the script.
|
||||
Default: '5270400' (61 day).
|
||||
|
||||
.PARAMETER LastWriteTime
|
||||
Time since file modification (in seconds). E.g.: '5270400'.
|
||||
If the time since file modification is greater than the specified value, they will be processed by the script.
|
||||
Default: '5270400' (61 day).
|
||||
|
||||
.PARAMETER FileSize
|
||||
File size check. E.g.: '5kb' / '12mb'.
|
||||
If the file size is greater than the specified value, they will be processed by the script.
|
||||
Default: '0kb'.
|
||||
|
||||
.PARAMETER Exclude
|
||||
Path to the file with exceptions. E.g.: 'C:\Exclude.TXT'.
|
||||
The values specified in this file will be ignored by the script. Wildcards are supported.
|
||||
|
||||
.PARAMETER Logs
|
||||
Path to the directory with logs. E.g.: 'C:\Logs'.
|
||||
|
||||
.PARAMETER RemoveDirs
|
||||
Removing empty directories.
|
||||
Default: 'false'.
|
||||
|
||||
.PARAMETER Overwrite
|
||||
Overwrite existing files in Vault.
|
||||
Default: 'false'.
|
||||
|
||||
.EXAMPLE
|
||||
Start-Vault -Source 'C:\Source' -Vault 'D:\Vault'
|
||||
|
||||
.EXAMPLE
|
||||
Start-Vault -Source 'C:\Source' -Vault 'D:\Vault' -CreationTime '864000' -LastWriteTime '864000'
|
||||
|
||||
.EXAMPLE
|
||||
Start-Vault -Source 'C:\Source' -Vault 'D:\Vault' -CreationTime '864000' -LastWriteTime '864000' -FileSize '32mb'
|
||||
#>
|
||||
|
||||
param(
|
||||
[Parameter(HelpMessage="Script operation mode. Default: 'MV'.")]
|
||||
[ValidateSet('CP', 'MV', 'RM')]
|
||||
[Alias('M')][string]$Mode = 'MV',
|
||||
|
||||
[Parameter(Mandatory, HelpMessage="Path to the source. E.g.: 'C:\Data\Source'.")]
|
||||
[Alias('SRC')][string]$Source,
|
||||
|
||||
[Parameter(Mandatory, HelpMessage="Path to the Vault. E.g.: 'C:\Data\Vault'.")]
|
||||
[Alias('DST')][string]$Vault,
|
||||
|
||||
[Parameter(HelpMessage="Time since file creation (in seconds). E.g.: '5270400'. Default: 61 day (5270400 sec.).")]
|
||||
[ValidateSet('CP', 'MV', 'RM')][Alias('M')][string]$Mode = 'MV',
|
||||
[Parameter(Mandatory)][Alias('SRC')][string]$Source,
|
||||
[Parameter(Mandatory)][Alias('DST')][string]$Vault,
|
||||
[Alias('CT')][long]$CreationTime = 5270400,
|
||||
|
||||
[Parameter(HelpMessage="Time since file modification (in seconds). E.g.: '5270400'. Default: 61 day ('5270400' sec.).")]
|
||||
[Alias('WT')][long]$LastWriteTime = $CreationTime,
|
||||
|
||||
[Parameter(HelpMessage="File size check. E.g.: '5kb' / '12mb'. Default: '0kb'.")]
|
||||
[Alias('FS')][string]$FileSize = '0kb',
|
||||
|
||||
[Parameter(HelpMessage="Path to the file with exceptions. E.g.: 'C:\Data\exclude.txt'.")]
|
||||
[Alias('E')][string]$Exclude = "$(Join-Path (Split-Path $PSScriptRoot -Parent) 'Vault.Exclude.txt')",
|
||||
|
||||
[Parameter(HelpMessage="Path to the directory with logs. E.g.: 'C:\Data\Logs'.")]
|
||||
[Alias('L')][string]$Logs = "$(Join-Path (Split-Path $PSScriptRoot -Parent) 'Logs')",
|
||||
|
||||
[Parameter(HelpMessage="Removing empty directories.")]
|
||||
[Alias('RD')][switch]$RemoveDirs = $false,
|
||||
|
||||
[Parameter(HelpMessage="Overwrite existing files in Vault.")]
|
||||
[Alias('O')][switch]$Overwrite = $false
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue