Hi CodeGeek,
Here's an example of how to accomplish the first three goals with PowerShell. You can use the send email operator in PAM to accomplish the fourth. Input this code into a "Run Script" operator and check the box "Post output to logs". This saves the output to the operator and can be used in a following Send Email operator.
Once you've saved this process you can create a schedule in PAM that fires this process once a week.
The variables at the top of the script need to be adjusted to match your environment.
<######################################################################
Service Desk Manager Variables
######################################################################>
$sdm_bg_srvr = "background_fqdn"
$sdm_sb_srvr = "standby_fqdn"
$sdm_app_srvrs = @("app_fqdn1","app_fqdn2","app_fqdn3","app_fqdn4","app_fqdn5","app_fqdn6")
$service = "CA Service Desk Manager Server"
$WebServiceProtocol = 'http://'
$WebServiceString = ':8080/axis/services/USD_R11_WebService?wsdl'
[String]$Login = 'webservice_user'
[String]$Password = 'webservice_password'
#####Restart Background and Standby Services#####
if(!(Test-Connection -Cn $sdm_bg_srvr -BufferSize 16 -Count 1 -ea 0 -quiet)){
Write-Host "Unable to contact $sdm_bg_srvr" -ForegroundColor Red
}
elseif(!(Test-Connection -Cn $sdm_sb_srvr -BufferSize 16 -Count 1 -ea 0 -quiet)){
Write-Host "Unable to contact $sdm_sb_srvr" -ForegroundColor Red
}
else{
Write-Host "Promoting $sdm_sb_srvr to the Background Server" -ForegroundColor Green
icm -cn $sdm_sb_srvr -ScriptBlock {pdm_server_control -b}
Write-Host "Suppress Version Control on $sdm_bg_srvr" -ForegroundColor Green
icm -cn $sdm_bg_srvr -ScriptBlock {pdm_server_control -v}
Write-Host "Wait 10 seconds before starting Services on $sdm_bg_srvr" -ForegroundColor Green
Start-Sleep -s 10
$getsvc = Get-Service -cn $sdm_bg_srvr -name $service
$statusBG = $getsvc.Status
if($statusBG -eq "Stopped"){
(get-service -ComputerName $sdm_bg_srvr -name $service).Start()
"_________________________________________________"
Write-Host "$service is Starting on $sdm_bg_srvr" -ForegroundColor Green
}
else{
Write-Host "$sdm_bg_srvr $service service is already $statusBG" -ForegroundColor Yellow
}
Write-Host "Wait 2 minutes for services to start on $sdm_bg_srvr" -ForegroundColor Green
Start-Sleep -s 60
Write-Host "Promoting $sdm_bg_srvr to the Background Server" -ForegroundColor Green
icm -cn $sdm_bg_srvr -ScriptBlock {pdm_server_control -b}
Write-Host "Wait 10 seconds before starting Services on $sdm_sb_srvr" -ForegroundColor Green
Start-Sleep -s 10
$getsvc = Get-Service -cn $sdm_sb_srvr -name $service
$statusSB = $getsvc.Status
if($statusSB -eq "Stopped"){
(get-service -ComputerName $sdm_sb_srvr -name $service).Start()
Write-Host "$service is Starting on $sdm_sb_srvr" -ForegroundColor Green
}
else{
Write-Host "$sdm_sb_srvr $service service is already $statusSB" -ForegroundColor Yellow
}
"_________________________________________________"
#####Restart Application Services#####
ForEach($srvr in $sdm_app_srvrs){
if(!(Test-Connection -Cn $srvr -BufferSize 16 -Count 1 -ea 0 -quiet)){
Write-Host "Unable to contact $srvr" -ForegroundColor Red
}
else{
$getsvc = Get-Service -cn $srvr -name $service
$status = $getsvc.Status
if($status -eq "Running"){
(get-service -ComputerName $srvr -name $service).Stop()
Write-Host "$service is Stopping on $srvr `n" -ForegroundColor Green
}
else{
Write-Host "$srvr $service service is already $status `n" -ForegroundColor Yellow
}
Write-Host "Wait 2 minutes before starting Services on $srvr" -ForegroundColor Green
Start-Sleep -s 120
$getsvc = Get-Service -cn $srvr -name $service
$status = $getsvc.Status
if($status -eq "Stopped"){
(get-service -ComputerName $srvr -name $service).Start()
Write-Host "$service is Starting on $srvr `n" -ForegroundColor Green
}
else{
Write-Host "$srvr $service service is already $status `n" -ForegroundColor Yellow
}
Write-Host "Wait 3 minutes before checking web service on $srvr" -ForegroundColor Green
Start-Sleep -s 180
# WebService connection
$URI = $WebServiceProtocol + $srvr + $WebServiceString
#Write-Host "URI: " $URI
$WebService = New-WebServiceProxy -uri $URI -Namespace WebServiceProxy -ErrorAction Stop
# Connection to Service Desk
$SID = $WebService.login($Login, $Password)
#Write-Host "SID: " $SID
$CountPri = $($WebService.doQuery($SID, "pri", "delete_flag = 0"))
#There should only be six priority values as this table can't be added to
if($CountPri.listLength -eq 6){
Write-Host "Successful webservice connection to $srvr" -ForegroundColor Green
Write-Host "`t" $CountPri.listLength " Priorities values found" -ForegroundColor Green
}
else{
Write-Host "Failed webservice query on $srvr" -ForegroundColor Red
}
$WebService.logout($SID)
"_________________________________________________"
}
}
}