-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parar-Servicos.ps1
68 lines (63 loc) · 2.05 KB
/
Parar-Servicos.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<#
Script para parar e desativar servicos a serem migrados
a partir do servidor antigo.
Servicos considerados:
IIS/FTP
WINS
MSSQLSERVER
SQLSERVERAGENT
UN2
MngAgent
SnaRpcService
SnaBase
SnaREM1
SnaServr
S580REPL
SEAP-TRANSFER
SrvRepEnvia
SrvRepRecebe
InterdominioRV
TranslogSRV
mapcrzd
mapextr
mplua
octagrmip
pr
#>
$ErrorActionPreference = "Stop"
$Domain = "dominio.Cliente"
$FileCSV = "C:\MIGRA\Planilha_Migracao.csv"
$ServidorAntigo = $((Import-Csv $FileCSV -Delimiter ";").HOSTNAMEATUAL) + "." + $Domain
[String[]]$Servicos = "MSSQLSERVER","SQLSERVERAGENT","UN2","MngAgent","SnaRpcService", `
"SnaBase","SnaREM1","SnaServr","S580REPL","SEAP-TRANSFER", `
"SrvRepEnvia","SrvRepRecebe","InterdominioRV","TranslogSRV", `
"mapcrzd","mapextr","mplua","octagrmip","pr","WINS","W3SVC","MSFTPSVC"
Write-Host "Parando servicos..."
Write-Host
ForEach ($Serv in $Servicos) {
Write-Host; Write-Host "Parando servico " $Serv "... " -NoNewline
Try {
Get-Service -ComputerName $ServidorAntigo -Name $Serv | Stop-Service -Force | Out-Null
}
Catch {
Write-Host
Write-Host -ForegroundColor Red "Problemas ao parar servico " $Serv "! Verifique diretamente no servidor."
Write-Host -ForegroundColor Red "Mensagem de Erro: " $_.Exception.Message
Write-Host -ForegroundColor Red "Item: " $_.Exception.Item
}
Write-Host "feito."
Write-Host "Desativando servico " $Serv "... " -NoNewline
Try {
Get-Service -ComputerName $ServidorAntigo -Name $Serv | Set-Service -StartupType Disabled | Out-Null
}
Catch {
Write-Host
Write-Host -ForegroundColor Red "Problemas ao desativar servico " $Serv "! Verifique diretamente no servidor."
Write-Host -ForegroundColor Red "Mensagem de Erro: " $_.Exception.Message
Write-Host -ForegroundColor Red "Item: " $_.Exception.Item
}
Write-Host "feito."
}
Write-Host
Write-Host "Script finalizado."
Write-Host