-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0627e9
commit 07331bf
Showing
1 changed file
with
55 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,63 @@ | ||
cls | ||
|
||
<# | ||
$Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() | ||
$AllComputers = ($Forest.Sites | % { $_.Servers } | SORT Domain,name).Name | ||
#> | ||
Write-Host 'Updating Agents!' | ||
$AllComputers = 'DomainController1.contoso.com' | ||
function Time-Stamp | ||
{ | ||
$TimeStamp = Get-Date -Format "MM/dd/yyy hh:mm:ss tt" | ||
Write-Host $TimeStamp -NoNewLine -ForegroundColor DarkGray | ||
} | ||
Write-Host @" | ||
==================== | ||
Updating SCOM Agents | ||
==================== | ||
"@ | ||
$AllComputers = 'DC01.contoso.com' | ||
ForEach ($Computer in $AllComputers) | ||
{ | ||
Write-Host "*** $Computer ***" | ||
##$Computer | ||
Copy-Item "C:\Temp\MOMAgent.msi" "\\$Computer\C`$\temp\" -Force -ErrorAction Stop | ||
Copy-Item "C:\Temp\KB4580254-amd64-Agent.msp" "\\$Computer\C`$\temp\" -Force -ErrorAction Stop | ||
Invoke-Command -ComputerName $Computer -ScriptBlock { | ||
$path_to_install = 'C:\Temp\MOMAgent.msi' | ||
Write-Host "Uninstalling Agent" | ||
start-process -FilePath "msiexec.exe" -ArgumentList "/x $path_to_install /qn /l*v C:\Temp\AgentUninstall.log" | ||
$args = "USE_SETTINGS_FROM_AD=0 USE_MANUALLY_SPECIFIED_SETTINGS=1 MANAGEMENT_GROUP=ManagementGroup1 MANAGEMENT_SERVER_DNS=MS1.contoso.com MANAGEMENT_SERVER_AD_NAME=MS1.contoso.com SECURE_PORT=5723 ACTIONS_USE_COMPUTER_ACCOUNT=1 AcceptEndUserLicenseAgreement=1" | ||
$args = "/i " + $path_to_install + " /quiet /qn /l*v C:\Temp\SCOMAgentInstall.log " + $args | ||
# Install Ops Manager Agent | ||
Write-Host 'Installing MOMAgent.msi' | ||
start-process -FilePath "msiexec.exe" -ArgumentList $args | ||
sleep 10 | ||
Write-Host 'Starting HSLockdown' | ||
start-process -FilePath "C:\Program Files\Microsoft Monitoring Agent\Agent\HSLockdown.exe" -ArgumentList "/A `"NT Authority\System`"" | ||
sleep 10 | ||
Write-Host 'Restarting Microsoft Monitoring Agent.' | ||
Restart-Service HealthService -Force | ||
$path_to_install = 'C:\Temp\KB4580254-amd64-Agent.msp' | ||
$args = "AcceptEndUserLicenseAgreement=1" | ||
$args = "/i " + $path_to_install + " /quiet /qn /l*v C:\Temp\SCOMUpgradeInstall.log " + $args | ||
# Install Ops Manager Agent | ||
Write-Host 'Installing Agent Update Rollup' | ||
start-process -FilePath "msiexec.exe" -ArgumentList $args | ||
} | ||
Time-Stamp | ||
Write-Host " $Computer" -ForegroundColor DarkCyan | ||
##$Computer | ||
Copy-Item "C:\Temp\MOMAgent.msi" "\\$Computer\C`$\temp\" -Force -ErrorAction Stop | ||
Copy-Item "C:\Temp\KB4580254-amd64-Agent.msp" "\\$Computer\C`$\temp\" -Force -ErrorAction Stop | ||
Invoke-Command -ComputerName $Computer -ScriptBlock { | ||
Stop-process -Name msiexec -Force | ||
function Time-Stamp | ||
{ | ||
$TimeStamp = Get-Date -Format "MM/dd/yyy hh:mm:ss tt" | ||
Write-Host $TimeStamp -NoNewLine -ForegroundColor DarkGray | ||
} | ||
$path_to_install = 'C:\Temp\MOMAgent.msi' | ||
# Uninstall Agent | ||
Time-Stamp | ||
Write-Host "`t - Uninstalling Agent" -ForegroundColor Cyan | ||
start-process -FilePath "msiexec.exe" -ArgumentList "/x $path_to_install /qn /l*v C:\Temp\AgentUninstall.log" -Wait -ErrorAction Stop | ||
Sleep 1 | ||
$args = "USE_SETTINGS_FROM_AD=0 USE_MANUALLY_SPECIFIED_SETTINGS=1 MANAGEMENT_GROUP=ManagementGroup1 MANAGEMENT_SERVER_DNS=MS1.contoso.com MANAGEMENT_SERVER_AD_NAME=MS1.contoso.com SECURE_PORT=5723 ACTIONS_USE_COMPUTER_ACCOUNT=1 AcceptEndUserLicenseAgreement=1" | ||
$args = "/i " + $path_to_install + " /quiet /qn /l*v C:\Temp\SCOMAgentInstall.log " + $args | ||
# Install Ops Manager Agent | ||
Time-Stamp | ||
Write-Host "`t - Installing MOMAgent.msi" -ForegroundColor Cyan -NoNewLine | ||
start-process -FilePath "msiexec.exe" -ArgumentList $args -Wait -ErrorAction Stop | ||
|
||
sleep 1 | ||
Time-Stamp | ||
Write-Host "`t - Adding 'NT Authority\System' to HSLockdown" -ForegroundColor Cyan | ||
start-process -FilePath "C:\Program Files\Microsoft Monitoring Agent\Agent\HSLockdown.exe" -ArgumentList "/A `"NT Authority\System`"" -Wait -ErrorAction Stop | ||
sleep 1 | ||
Time-Stamp | ||
Write-Host "`t - Restarting Microsoft Monitoring Agent" -ForegroundColor Cyan | ||
Restart-Service HealthService -Force | ||
# Install Ops Manager Agent Update Rollup | ||
$path_to_install = 'C:\Temp\KB4580254-amd64-Agent.msp' | ||
$msiArgs = "/update `"$path_to_install`" /quiet" | ||
Time-Stamp | ||
Write-Host "`t - Installing Agent Update Rollup" -ForegroundColor Cyan -NoNewLine | ||
Start-Process -FilePath msiexec -ArgumentList $msiArgs -Wait -ErrorAction Stop | ||
Time-Stamp | ||
Write-Host "`t -- Complete!" -ForegroundColor Green | ||
} | ||
|
||
} |