Hello fellow members,
I do have a problem with my script, let me explain it.
What I want ?
to associate 1 or n files extension(s) to a folder
The XML File :
I cannot copy/paste the XML code it’s destroying the format …
[ol]{
SERVER-0001
SERVER-0001
D$\Hyperion\logs\openldap\
*.txt
D$\Hyperion\logs\BIPlus\
server_messages.log.*
Annotations.log.*
eiengine.log
}[/ol]
the script :
foreach ($server in $xmlfile.SI.Environnement.Foundation.SERVER) {
foreach($path in $xmlfile.SI.Environnement.Foundation.Paths.PATH) {
$fullpath = $path.FOLDER
$Exist = Test-Path “\$server$fullpath”
if ($Exist -eq “True”) {
write-host “directory :”$path.FOLDER “exist” on $Server
$TotalRemoved = Get-ChildItem “\$server$fullpath*” -Include $path.PATTERN | Where {$_.LastWriteTime -le “$Limit”} | Measure-Object | Select-Object -ExpandProperty Count
Write-host $TotalRemoved “files were removed with pattern” $path.PATTERN
}
elseif ($Exist -ne “True”) {
Write-Host “directory :”$fullpath “does not exist” on $Server
}
write-host `r
}
}
the code return :
directory : D$\Hyperion\logs\openldap\ exist on Server-0001
0 files were removed with pattern *.txt
directory : D$\Hyperion\logs\BIPlus\ exist on Server-0001
35 files were removed with pattern server_messages.log.* Annotations.log.* eiengine.log
directory : D$\Hyperion\logs\openldap\ does not exist on Server-0002
directory : D$\Hyperion\logs\BIPlus\ does not exist on Server-0002
The problem is in bold, I’d like “server_messages.log." on a line (as a variable to reuse, "Annotations.log.” on a sercond and “eiengine.log” on a thrid one.
Is there a way to get 1 or n extension(s) PER ?
thank you for your help