Database Size Limit in GB script

EMS to set the database size limit in the registry

$DBsize = "200"
$loc = get-location
[string]$server = $env:computername

$var1 = "HKLM:\System\CurrentControlSet\services\MSExchangeIS\"

$var2 = "\"
$var3 = "Database Size Limit In GB"
$var4 = “*Database Size Limit In GB*”
$var5 = "\Logstate"

$regkeys = (Get-ChildItem -path $var1$server)


Set-location -path REGISTRY::


foreach ($regkey in $regkeys){

$key = (Get-ItemProperty -path $regkey); if ($key -notlike $var4){New-ItemProperty -path $regkey -name $var3 -value $DBsize -PropertyTYpe "DWord"}
}

Remove-itemProperty $var1$server$Var5 -name $var3 -confirm:$false


set-location -path $loc