Last active
January 27, 2022 17:15
-
-
Save infamousjoeg/6a2a3377037c92c0a35ac9379fd0fb90 to your computer and use it in GitHub Desktop.
For directory monitoring and collection of XML files...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# VARIABLES | |
## XMLWatcher Variables | |
$XMLWatcher = New-Object System.IO.FileSystemWatcher | |
$XMLWatcher.Path = "C:\Program Files (x86)\CyberArk\PasswordManager\tmp" | |
$XMLWatcher.Filter = "*.xml" | |
# REGISTER PSJOB TO MONITOR FOR FILE SYSTEM CHANGES | |
Register-ObjectEvent $XMLWatcher -EventName Created -Action { | |
$datestamp = Get-Date -UFormat "%Y%m%d%H%M%S" | |
Write-Host "[${datestamp}] $($eventArgs.FullPath)" | |
Copy-Item $eventArgs.FullPath "C:\Windows\Temp\$datestamp.xml" | |
} | |
#Unregister-Event $object.Id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment