Code: Select all
$form1_Load={
$policyexists = Test-Path HKLM:\SOFTWARE\Policies\Google\Chrome
$policyexistshome = Test-Path HKLM:\SOFTWARE\Policies\Google\Chrome\RestoreOnStartupURLs
$regKeysetup = "HKLM:\SOFTWARE\Policies\Google\Chrome"
$regKeyhome = "HKLM:\SOFTWARE\Policies\Google\Chrome\RestoreOnStartupURLs"
$url = "https://OurCompany.sharepoint.com/sites/corpportal"
if ($policyexists -eq $false)
{
New-Item -path HKLM:\SOFTWARE\Policies\Google
New-Item -path HKLM:\SOFTWARE\Policies\Google\Chrome
New-ItemProperty -path $regKeysetup -Name PasswordManagerEnabled -PropertyType DWord -Value 0
New-ItemProperty -path $regKeysetup -Name RestoreOnStartup -PropertyType Dword -Value 4
New-ItemProperty -path $regKeysetup -Name HomepageLocation -PropertyType String -Value $url
New-ItemProperty -path $regKeysetup -Name HomepageIsNewTabPage -PropertyType DWord -Value 0
}
Else
{
Set-ItemProperty -Path $regKeysetup -Name PasswordManagerEnabled -Value 0
Set-ItemProperty -Path $regKeysetup -Name RestoreOnStartup -Value 4
Set-ItemProperty -Path $regKeysetup -Name HomepageLocation -Value $url
Set-ItemProperty -Path $regKeysetup -Name HomepageIsNewTabPage -Value 0
}
if ($policyexistshome -eq $false)
{
New-Item -path HKLM:\SOFTWARE\Policies\Google\Chrome\RestoreOnStartupURLs
New-ItemProperty -path $regKeyhome -Name 1 -PropertyType String -Value $url
}
Else
{
Set-ItemProperty -Path $regKeyhome -Name 1 -Value $url
}
$form1.Close()
}
In PowerShell Stuido I have tried the following.
Settings:
Script Engine: v3 host (windows forms)
output settings: No Manifest, alternate credentials Domain\AdminUser Password: P@$$word (this is an admin account that has local admin rights)
using these settings does not work. I run the compiled .EXE and it does not change the Chrome homepage. I have right clicked my .EXE and picked both "run as Admin" and "run as different user" and neither works.
Thanks for any help you can provide.