#Defining Variables
##Path to HKLM keys
$HKLMregistryPath = 'HKLM:\SOFTWARE\Policies\Microsoft\OneDrive'
#Create Function
Function New-RegistryKey {
if (!(Test-Path $HKLMRegistryPath)) {
Write-Host 'Registry Key Not Found, Creating Key'
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft' -Name OneDrive -Force
}
else {
Write-Host "Key Already Present"
Get-Item $HKLMregistryPath
}
}
Function New-RegistryKeyAutoMount {
if (!(Test-Path $AutoMountKey)) {
Write-Host 'Registry Key Not Found, Creating Key'
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\OneDrive' -Name TenantAutoMount -Force
}
else {
Write-Host "Key Already Present"
Get-Item $AutoMountKey
}
}
#Run Functions
New-RegistryKey
New-RegistryKeyAutoMount
#Create the Values
##Redirect WKFs silently
New-ItemProperty -Path $HKLMregistryPath -Name "KFMSilentOptIn" -Value $AzureTenantID -PropertyType "String" -Force
##Redirect with wizard
New-ItemProperty -Path $HKLMregistryPath -Name "KFMOptInWithWizard" -Value $AzureTenantID -PropertyType "String" -Force
##Enable Files on Demand
New-ItemProperty -Path $HKLMregistryPath -Name "FilesOnDemandEnabled" -Value 1 -PropertyType DWORD -Force
##Enable silent account configuration
New-ItemProperty -Path $HKLMregistryPath -Name "SilentAccountConfig" -Value 1 -PropertyType DWORD -Force
##Block Opt Out
New-ItemProperty -Path $HKLMregistryPath -Name "KFMBlockOptOut" -Value 1 -PropertyType DWORD -Force
##Enable Automatic Upload Bandwidth Management
New-ItemProperty -Path $HKLMregistryPath -Name "EnableAutomaticUploadBandwidthManagement" -Value 1 -PropertyType DWORD -Force
##Block file downloads when users are low on disk space
New-ItemProperty -Path $HKLMregistryPath -Name "MinDiskSpaceLimitInMB" -Value 5120 -PropertyType DWORD -Force
##Set OneDrive to Production Ring
New-ItemProperty -Path $HKLMregistryPath -Name "GPOSetUpdateRing" -Value 5 -PropertyType DWORD -Force
##Enable Sync Admin Reports
if ($TenantKey) {
New-ItemProperty -Path $HKLMregistryPath -Name "SyncAdminReports" -Value $TenantKey -PropertyType "String" -Force
}
else {
Write-Host "TenantKey parameter was not defined"
}