64 lines
4.1 KiB
PowerShell
64 lines
4.1 KiB
PowerShell
Function Get-Item-withLogging {
|
||
|
||
<#
|
||
.SYNOPSIS
|
||
Function will check the given Path for existence.
|
||
.DESCRIPTION
|
||
Function will check the given Path for existence. It returns always just ONE Value!
|
||
.REQUIREMENT General
|
||
PowerShell V2 and Function "Func-Write-Logfile".
|
||
.REQUIREMENT Variables
|
||
Path, PathTest
|
||
.REQUIREMENT Functions
|
||
.VERSION
|
||
Number: 1.1.0.0 / Date: 09.02.2016
|
||
.EXAMPLE
|
||
Func-Path-Check -Path "E:\Path\to\check"
|
||
.EXAMPLE
|
||
Func-Path-Check -Path "E:\Path\to\create"
|
||
.PARAMETER Path
|
||
Give the full Path you want to check or create.
|
||
#>
|
||
|
||
Param
|
||
(
|
||
[String]$SearchPath,
|
||
[Array]$SearchWhiteList,
|
||
[Array]$SearchBlackList,
|
||
[bool]$RecurseSwitch,
|
||
[String]$FileDelayAge
|
||
)
|
||
|
||
Set-Variable -Name SearchWhiteList -Value ($SearchWhiteList -Replace " ","")
|
||
Set-Variable -Name SearchWhiteList -Value ($SearchWhiteList -Split ",")
|
||
Set-Variable -Name SearchWhiteList -Value ($SearchWhiteList -Split ";")
|
||
|
||
Set-Variable -Name SearchBlackList -Value ($SearchBlackList -Replace " ","")
|
||
Set-Variable -Name SearchBlackList -Value ($SearchBlackList -Split ",")
|
||
Set-Variable -Name SearchBlackList -Value ($SearchBlackList -Split ";")
|
||
|
||
$Items = Get-ChildItem -Path "$SearchPath" -include $SearchWhiteList -exclude $SearchBlackList -Recurse | where-object {$_.lastwritetime -lt (get-date).addminutes(-$FileDelayAge)}
|
||
IF ($Items -eq $NULL) {
|
||
|
||
Func-Write-Logfile -LogLine "Could not find any File(s) in Path: $SearchPath (regard on White and Black Lists)."
|
||
|
||
Return $NULL
|
||
|
||
} #end if
|
||
|
||
ELSE {
|
||
|
||
Func-Write-Logfile -LogLine "Could find some File(s) in Path: $SearchPath (regard on White and Black Lists) ..."
|
||
FOREACH ($Item in $Items) {
|
||
|
||
Func-Write-Logfile -LogLine "...found File: $Item"
|
||
|
||
} #end foreach
|
||
|
||
Return $Items
|
||
|
||
} #end else
|
||
|
||
} #end function
|
||
|
||
Export-ModuleMember -Function Get-Item-withLogging |