It works great - I added it to Task Scheduler, but I had to change
$frontCamera = Get-PnpDevice -Class Camera -Status OK | Where-Object { $_.FriendlyName -match "Front|Integrated" -and $_.FriendlyName -notmatch "Hello|IR|Infrared" } return $frontCamera
to
$frontCamera = Get-PnpDevice -Class Camera -Status OK | Where-Object { $_.DeviceId -eq "USB\VID_0C45&PID_6728&MI_00\6&230D12BB&0&0000" } return $frontCamera
for my Dell. ChatGPT helped me with it.
Anyway, selecting a device by "FriendlyName" is misleading.