Posts

Showing posts from June, 2024

PowerShell script to automate BGInfo update every hour

 # PowerShell script to automate BGInfo update every hour # Variables $sourcePath = "\\win1\c$\Windows\SYSVOL\sysvol\apex.local\scripts"  # Example path "\\YourServer\SharedFolder" $destinationPath = "C:\ProgramData\Packages\bginfo"  # Example path "C:\LocalFolder" $bgInfoExecutable = "Bginfo64.exe" $configFile = "config.bgi" # Function to copy files if they are updated function Update-Files {     $sourceFiles = Get-ChildItem -Path $sourcePath     foreach ($file in $sourceFiles) {         $localFile = Join-Path -Path $destinationPath -ChildPath $file.Name         if (Test-Path $localFile) {             $localFileInfo = Get-Item $localFile             if ($localFileInfo.LastWriteTime -lt $file.LastWriteTime) {                 Copy-Item -Path $file.FullName -Destination $localFile -Force             }         } else {             Copy-Item -Path $file.FullName -Destination $localFile         }     } } # Function to schedule BGIn

PowerShell script to automate BGInfo update without user input

# PowerShell script to automate BGInfo update without user input # Variables $sourcePath = "\\YourServer\SharedFolder" $destinationPath = "C:\LocalFolder" $bgInfoExecutable = "Bginfo.exe" $configFile = "config.bgi" $scheduledTime = "06:00" # Set your desired time in HH:mm format # Function to copy files if they are updated function Update-Files {     $sourceFiles = Get-ChildItem -Path $sourcePath     foreach ($file in $sourceFiles) {         $localFile = Join-Path -Path $destinationPath -ChildPath $file.Name         if (Test-Path $localFile) {             $localFileInfo = Get-Item $localFile             if ($localFileInfo.LastWriteTime -lt $file.LastWriteTime) {                 Copy-Item -Path $file.FullName -Destination $localFile -Force             }         } else {             Copy-Item -Path $file.FullName -Destination $localFile         }     } } # Function to schedule BGInfo update function Schedule-BGInfoUpdate {     $action = N