Hi all.
I’m (very) new to the world of Powershell Scripting so please be patient with me
When our developers finish a new version of their app, its is getting deployed to a testing-machine. But in order to install the new version, the old needs to be stopped first, which shall be done with a simple PS script.
Unfortunately our byte-forgers made the “current version string” part of the app’s name. So I can’t just hardwire the “Service Name” to do a simple stop …
So here is my task: Find the current running Service, stop it … if there’re some processes left, kill 'em. Install/deploy the new version and start the Service afterwards.
Her is a “part” of the Script:
function get-proc {
param ( $service_name )
$Service=get-wmiobjectwin32_service|where { $_.name -match $service_name }
if ($Service -ne $null ){
$global:procID=$Service.ProcessId
$global:serviceID=$Service.Name
}
Write-Output $Service
}
functionstop-service {
param ( $service_name )
foreach ( $srvsID in $global:serviceID ) {
Write-Output "stopping: $srvsID"
Stop-Service -Name $srvsID -Force
}
Sometimes the script finishes … but nothing (ever) happens. No error thrown, Service still running.
But sometimes it crashes with:
"Script failed du to call depth overflow. "
Can you help me out ?