• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
ControlUp Community

ControlUp Community

Connect, Learn, and Grow

  • Blog
  • Podcast
  • Meetups
  • Archives
  • Categories
    • ControlUp One Platform
    • ControlUp for Apps
    • ControlUp for Compliance
    • ControlUp for Desktops
    • ControlUp Scripts & Triggers
    • ControlUp Synthetic Monitoring
    • ControlUp for VDI
  • Topics
  • Events
    • Logos & Wallpaper
    • ControlUp.com
  • Join

Creating a Trigger to Compare Two PVS Stores in ControlUp

Posted on September 15, 2023

A user asked for help creating a trigger which compares two PVS stores and sends an email if not identical. @member suggested ChatGPT, which can add an error to the event log if the contents are not the same, and a second trigger can be set up for the error. A PowerShell script was provided which writes an error message to the event log if changes are present in the folders, with the needed event log name, source, and EventId customizable.


Read the entire ‘Creating a Trigger to Compare Two PVS Stores’ thread below:

Hi all, I would like to create a trigger which compares both PVS Stores and sends an email if they are not identical = admin forgot to copy the vdisk from A to B. Any ideas how I could achieve this?


@member – I bet you have something similar available already ? (to be run as a scheduled trigger)


I don’t have anything but ChatGPT does! 🙂 https://chat.openai.com/share/9bd5926d-14a1-4ecd-9806-1b4edf1fd627

I had it add an error to the event log if the contents are not the same. You can then setup a second trigger on this error and fire an alert.

To write an error to the event log if changes are present in the folders, you can modify the PowerShell script as follows:

“`powershell

Define the paths to the two folders you want to compare

$folder1Path = "C:\Path\To\Folder1"

$folder2Path = "C:\Path\To\Folder2"

Get the list of files and subfolders in each folder

$folder1Contents = Get-ChildItem -Path $folder1Path -File -Recurse

$folder2Contents = Get-ChildItem -Path $folder2Path -File -Recurse

Compare the contents of the two folders

$folder1Only = Compare-Object -ReferenceObject $folder1Contents -DifferenceObject $folder2Contents | Where-Object { $_.SideIndicator -eq "

$folder2Only = Compare-Object -ReferenceObject $folder1Contents -DifferenceObject $folder2Contents | Where-Object { $_.SideIndicator -eq "=>" }

Check if the folders have the same content

if ($folder1Only.Count -eq 0 -and $folder2Only.Count -eq 0) {

Write-Host "Both folders have the same contents."

} else {

Write-Host "Folders have different contents."

# Create an error message

$errorMessage = "Folders $folder1Path and $folder2Path have different contents."

# Write the error message to the event log

Write-EventLog -LogName Application -Source "FolderComparisonScript" -EntryType Error -EventId 1 -Message $errorMessage

# You can replace "Application" with the desired event log name

# "FolderComparisonScript" is used as the source, and you can customize it as needed

# EventId 1 is an example; you can use a different EventId

}

“`

This script will write an error message to the Application event log if changes are present in the folders. You can customize the event log name, source, and EventId as needed. Make sure to replace $folder1Path and $folder2Path with the actual folder paths you want to compare.

Continue reading and comment on the thread ‘Creating a Trigger to Compare Two PVS Stores in ControlUp’.  Not a member? Join Here!


Categories: All Archives, ControlUp Scripts & Triggers
Topics: Automation & Alerting, Citrix Provisioning Services (PVS), Logs, PowerShell, Scripts, Triggers

Ask Us Anything, Connect, Learn, and Grow with the ControlUp Community!

Login to the ControlUp Community to ask us anything, stay up-to-date on what’s new and coming soon and meet other like-minded techies like you.

Not already a member? Join Today!

Primary Sidebar

ControlUp Academy

Enroll in ControlUp Academy for expert-led technical training, equipping you with skills to effectively deploy, manage, and grow your ControlUp investment.

Learn here >

Rotating Images

Hidden Gem from our Community on Slack!

ControlUp Betas - What's Coming Next?
NEW ControlUp Features - Stay Up-to-Date!
ControlUp Scripts - Scripting, Zero to Hero
Latest KB Articles - Be the First to Learn
Did you Know - with Sivan Kroitoru
Practical Perspectives Technical Use Case Training

Video Tutorials Library

Visit our technical how-to videos, offering step-by-step tutorials on advanced features, troubleshooting, and best practices.

Watch here >

ControlUp Blog

Check out the ControlUp blog for expert advice and in-depth analysis.

Read here >

ControlUp Script Library

Visit the ControlUp technical script library, which offers a multitude of pre-built scripts and custom actions for your monitoring and troubleshooting requirements.

See here >

ControlUp Support

Visit the ControlUp support home and to delve deeper into ControlUp solutions.

Browse here >

Download ControlUp RealTime DX

Start with ControlUp for real-time end-user environment insights, swift troubleshooting, and unprecedented performance optimization. Download now.

Download here >

Footer

      

ControlUp Community
Of Techie, By Techie, For Techie!

Terms of Use | Privacy Policy | Security
Dive Deeper, Learn more at ControlUp.com

  • facebook
  • twitter
  • youtube
  • linkedin

© 2023–2025 ControlUp Technologies LTD, All Rights Reserved.

We use cookies to ensure that we give you the best experience on our website. by continuing to use this site you agree to our Cookie policy..