Open Srikanth1455 opened 1 year ago
Might not be everything you are looking for but we've got 4-5 locations and someone wrote this script to search sub dir's for vCheck.ps1 and run it. So put a vCheck_USA, vCheck_France directory under the script.
$strSMTP = "eemail.home.now"
$strFrom = "yourcomputer@home.now"
$arTo = @("me@home.now")
$strSubject = "vCheck Reports"
$strMessage = "See attached vCheck Reports"
$ScriptPath = (Split-Path ((Get-Variable MyInvocation).Value).MyCommand.Path)
$ScriptInstances = Get-ChildItem -Path $ScriptPath -Filter vcheck.ps1 -Recurse Remove-Item -Path "$ScriptPath\Output*" -Recurse Foreach ($instance in $ScriptInstances) { $command = $instance.FullName + " –OutputPath $ScriptPath\Output" Invoke-Expression -Command $command }
$outputHTM = Get-ChildItem -Path "$ScriptPath\OutPut" -Filter *.htm -Recurse $arAttachments = @() Foreach ($htm in $outputHTM) { $arTemp = $htm.BaseName.Split(".") $newFileName = $arTemp[0] + ".htm" Rename-Item $htm.FullName $newfileName $newfileName = $htm.DirectoryName + "\" + $newFileName $arAttachments += $newFileName }
send-mailmessage -SmtpServer $strSMTP -From $strFrom -To $arTo -Subject $strSubject -Body $strMessage -Attachments $arAttachments
Remove-Item -Path "$ScriptPath\Output*" -Recurse