Quantcast
Channel: Forcepoint Community
Viewing all articles
Browse latest Browse all 2011

Restart Websense Services - Windows Powershell

$
0
0

Here's a powershell script to restart services remotely. I have an issue with the WebsenseControlService returning a "CouldNotStopService" -- yet it still appears to stop. Any ideas?

###START SCRIPT restart-websense.ps1 ###

<#
.Synopsis
Restarts Websense services without a machine restart.
.DESCRIPTION
Script restarts local or remote Websense Tritorn Web Security services in required safe order.
See http://www.websense.com/content/support/library/web/v75/triton_web_help/start_stop_services.aspx#636734 for service list
.EXAMPLE
Restart-WebsenseSvc
.EXAMPLE
Restart-WebsenseSvc host.domain.tld
.Credits
Jamie Bilinski / Alter Trading Corp
#>
function Restart-WebsenseSvc([string]$wsSvr = ".")
{
[array]$svcOrdLst=@('Websense Network Agent','Websense EIM Server','WebsensePolicyServer','WebsensePolicyBroker','WebsensePolicyDB','WebsenseControlService') #service name in stop order
[string]$svcLike="Websense*"
[int]$svcOrdCnt= $svcOrdLst.length - 1
$svcOtherWSLst = Get-Service -ComputerName $wsSvr | Where-Object {$_.name -like $svcLike} | Where-Object {$svcOrdLst -notcontains $_.Name}

Write-Host '*** Stopping Websense Services***'
foreach ($svcOtherWS in $svcOtherWSLst)
{
Write-Host "Requesting Stop of Service: $($svcOtherWS.DisplayName)..."
Stop-Service $svcOtherWS
}
for ($i=0; $i -le $svcOrdCnt; $i++)
{
Write-Host "Requesting Stop of Core Service: $($svcOrdLst[$i])..."
Get-Service -ComputerName $wsSvr -name $svcOrdLst[$i] | Stop-Service
}
Write-Host '*** Starting Websense Services ***'
for ($i=$svcOrdCnt; $i -ge 0; $i--)
{
Write-Host "Requesting Start of Core Service: $($svcOrdLst[$i])..."
Get-Service -ComputerName $wsSvr -name $svcOrdLst[$i] | Start-Service
}
foreach ($svcOtherWS in $svcOtherWSLst)
{
Write-Host "Requesting Start of Service: $($svcOtherWS.DisplayName)..."
Start-Service $svcOtherWS
}
} #end function

#usage: Restart-WebsenseSvc hostname
Restart-WebsenseSvc 'wsgw.domain.tld'

### END SCRIPT ###


Viewing all articles
Browse latest Browse all 2011

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>