# https://chat.openai.com/share/6d96527b-288d-45a9-8eb4-e8b43d52486a # Input parameters param ( [Parameter(Mandatory=$true)] [string]$inputFile, [Parameter(Mandatory=$true)] [System.Management.Automation.PSCredential]$Credential ) # Read hostnames from input file $hostnames = Get-Content $inputFile foreach ($hostname in $hostnames) { # Create directory for this hostname if it doesn't exist $directoryPath = ".\$hostname" if(!(Test-Path -Path $directoryPath )) { New-Item -ItemType directory -Path $directoryPath } # Source path where event logs are located in the remote system $sourcePath = "\\$hostname\C$\Windows\System32\winevt\Logs\" # Copy log files from remote host to local directory Copy-Item -Path $sourcePath -Destination $directoryPath -Recurse -Force }