Hello
I have this powershell that checked the directories for me.
Everything works fine.
Of course I get 3 emails through the forech.
My question:
is it possible to only receive one email with the content of the console?
Or an email with an overview of which files are different on the systems?
The Powershell script:
i mean this Output
I have this powershell that checked the directories for me.
Everything works fine.
Of course I get 3 emails through the forech.
My question:
is it possible to only receive one email with the content of the console?
Or an email with an overview of which files are different on the systems?
The Powershell script:
Code:
$ref_dir = '\\PC1\Share\123\xyz'
$filefilter = '*.pvx'
$shares = "\\PC2\Share\123\xyz","\\PC3\Share\123\xyz","\\PC4\Share\123\xyz"
$ref = ls "$ref_dir\*" -File -Filter $filefilter -exclude '*Cali*','*Light*','*ORG*','*org*','*save*','*EA*','*TEST*'
foreach ($share in $shares){
$diff = compare @($ref) @(ls "$share\*" -File -Filter $filefilter -exclude '*Cali*','*Light*','*ORG*','*org*','*save*','*EA*','*TEST*') -Property Name,LastWriteTime
if ($diff){
$diff | ft -AutoSize
Send-MailMessage –To "Email@xyz.com" `
–Subject ("ACHTUNG PVX DATEI UNTERSCHIEDLICH!")`
–Body ("Die Datei $($diff.Name) $($diff.LastWriteTime) ist auf $share unterschiedlich")`
–SmtpServer "smtp.com" `
–From "noreplay@domain.com" `
-encoding ([System.Text.Encoding]::UTF8)
}
}
i mean this Output
Code:
PS C:\Windows\System32\WindowsPowerShell\v1.0> U:\Test\Powershell\Check-PVX.ps1
\\PC2\Share\123\xyz hat unterschiedliche Dateien
Name LastWriteTime SideIndicator
---- ------------- -------------
Lx_St1.1_EVGV1_Defekte_Deckel_hinten.pvx 09.03.2021 08:22:06 =>
Lx_St1.1_EVGV1_Defekte_Deckel_hinten.pvx 09.03.1900 00:00:01 <=
\\PC3\Share\123\xyz hat unterschiedliche Dateien
Name LastWriteTime SideIndicator
---- ------------- -------------
Lx_St1.1_EVGV1_Defekte_Deckel_hinten.pvx 09.03.2021 08:22:06 =>
Lx_St1.1_EVGV1_Defekte_Deckel_hinten.pvx 09.03.1900 00:00:01 <=
\\PC4\Share\123\xyz hat unterschiedliche Dateien
Name LastWriteTime SideIndicator
---- ------------- -------------
Lx_St1.1_EVGV1_Defekte_Deckel_hinten.pvx 09.03.2021 08:22:06 =>
Lx_St1.1_EVGV1_Defekte_Deckel_hinten.pvx 09.03.1900 00:00:01 <=
PS C:\Windows\System32\WindowsPowerShell\v1.0>