How to automate PowerShell scripts with Jenkins

Опубликовано: 30 Март 2026
на канале: Fun & Tech
3,685
26

Jenkins is a free and open source automation server.
please like and subscribe.
How to install Jenkins watch my video    • How to Install Jenkins on Windows 10 and a...  

1st script to export event logs to a folder in HTML format.(HTML Format script is not complete here)

$Applog = Get-Eventlog -LogName application -EntryType Error,Warning -after ([datetime]::Today)
$syslog = Get-Eventlog -LogName System -EntryType Error,Warning -after ([datetime]::Today)
$Applog | ConvertTo-HTML -Head $css MachineName, Source, EventID, Message "C:\files\checkfolder\AppEvent.html"
$Syslog | ConvertTo-HTML -Head $css MachineName, Source, EventID, Message "C:\files\checkfolder\SysEvent.html"

2nd script to archive the files to archive folder.

$folderName = (Get-Date).tostring("dd-MM-yyyy-hh-mm-ss")
if( (Get-ChildItem C:\files\CheckFolder | Measure-Object).Count -eq 0)
{
echo "Folder is empty, exiting"
} else { $folder = New-Item -itemType Directory -Path C:\files\archive\ -Name $FolderName
echo "Folder has files, moving the files to $folder"
Move-Item -Path "C:\files\CheckFolder\*.*" -Destination "C:\files\archive\$FolderName"
}