馬賽版GCPW安裝

<# 這個指令碼會從 https://tools.google.com/dlpage/gcpw/ 下載 Google 憑證提供者 Windows 版,然後執行安裝及設定程序。
您必須擁有 Windows 管理員權限才能使用指令碼。#>

<# 請根據您要讓使用者從哪些網域登入,來設定以下機碼。

例如:
$domainsAllowedToLogin = “acme1.com,acme2.com”
#>

$domainsAllowedToLogin = “gmail.com,tmail.ilc.edu.tw,smail.ilc.edu.tw,mses.ilc.edu.tw,saes.ilc.edu.tw,yles.ilc.edu.tw”

Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName PresentationFramework

<# 請檢查您設定了 1 個還是多個網域 #>
if ($domainsAllowedToLogin.Equals(”)) {
$msgResult = [System.Windows.MessageBox]::Show(‘The list of domains cannot be empty!Please edit this script.’, ‘GCPW’, ‘OK’, ‘Error’)
exit 5
}

function Is-Admin() {
$admin = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match ‘S-1-5-32-544’)
return $admin
}

<# 檢查目前的使用者是否為管理員,如果不是的話,請結束此程序。#>
if (-not (Is-Admin)) {
$result = [System.Windows.MessageBox]::Show(‘Please run as administrator!’, ‘GCPW’, ‘OK’, ‘Error’)
exit 5
}

<# 選擇要下載的 GCPW 檔案。提醒您,32 位元和 64 位元版本的名稱各不相同 #>
$gcpwFileName = ‘gcpwstandaloneenterprise.msi’
if ([Environment]::Is64BitOperatingSystem) {
$gcpwFileName = ‘gcpwstandaloneenterprise64.msi’
}

<# 下載 GCPW 安裝程式。#>
$gcpwUrlPrefix = ‘https://dl.google.com/credentialprovider/’
$gcpwUri = $gcpwUrlPrefix + $gcpwFileName
Write-Host ‘Downloading GCPW from’ $gcpwUri
Invoke-WebRequest -Uri $gcpwUri -OutFile $gcpwFileName

<# 執行 GCPW 安裝程式並等待安裝完成 #>
$arguments = “/i `”$gcpwFileName`””
$installProcess = (Start-Process msiexec.exe -ArgumentList $arguments -PassThru -Wait)

<# 檢查是否已成功安裝 #>
if ($installProcess.ExitCode -ne 0) {
$result = [System.Windows.MessageBox]::Show(‘Installation failed!’, ‘GCPW’, ‘OK’, ‘Error’)
exit $installProcess.ExitCode
}
else {
$result = [System.Windows.MessageBox]::Show(‘Installation completed successfully!’, ‘GCPW’, ‘OK’, ‘Info’)
}

<# 將允許的網域名稱設為必要的登錄機碼值 #>
$registryPath = ‘HKEY_LOCAL_MACHINE\Software\Google\GCPW’
$name = ‘domains_allowed_to_login’
[microsoft.win32.registry]::SetValue($registryPath, $name, $domainsAllowedToLogin)

$domains = Get-ItemPropertyValue HKLM:\Software\Google\GCPW -Name $name

if ($domains -eq $domainsAllowedToLogin) {
$msgResult = [System.Windows.MessageBox]::Show(‘Configuration completed successfully!’, ‘GCPW’, ‘OK’, ‘Info’)
}
else {
$msgResult = [System.Windows.MessageBox]::Show(‘Could not write to registry. Configuration was not completed.’, ‘GCPW’, ‘OK’, ‘Error’)

}

您可能也會喜歡…

跳至工具列