Detection:
$Path = "HKCU:\SOFTWARE\Microsoft\OneDrive\Accounts\Business1"
$Name = "Timerautomount"
$Value = 1
Try {
$Registry = Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop | Select-Object -ExpandProperty $Name
If ($Registry -eq $Value) {
Write-Output "Timerautomount is set to $Value"
Exit 0
}
Write-Warning "Timerautomount is $Registry, expected $Value"
Exit 1
} Catch {
Write-Warning "Timerautomount not found or not readable: $($_.Exception.Message)"
Exit 1
}
Remediation:
$Path = "HKCU:\SOFTWARE\Microsoft\OneDrive\Accounts\Business1"
Try {
If (-not (Test-Path $Path)) { New-Item -Path $Path -Force | Out-Null }
New-ItemProperty -Path $Path -Name "Timerautomount" -Value 1 -PropertyType QWord -Force | Out-Null
Exit 0
} Catch {
Write-Warning $_.Exception.Message
Exit 1
}