-
Notifications
You must be signed in to change notification settings - Fork 0
/
Migrar-WINS.ps1
114 lines (106 loc) · 4.1 KB
/
Migrar-WINS.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Script para migrar as configuracoes do WINS
#
$ErrorActionPreference = "Stop"
$Domain = "dominio.Cliente"
$FileCSV = "C:\MIGRA\Planilha_Migracao.csv"
$FileLocal = "C:\MIGRA\SecureLocal.txt"
$UserLocal = "administrator"
$PassLocal = Cat $FileLocal | ConvertTo-SecureString
$FileCliente = "C:\MIGRA\SecureCliente.txt"
$UserCliente = "dominio\usuario"
$PassCliente = Cat $FileCliente | ConvertTo-SecureString
#
# Obtencao das Credenciais locais e do Cliente
$CredLocal = New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $UserLocal, $PassLocal
$CredCliente = New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $UserCliente, $PassCliente
$ServidorAntigo = $((Import-Csv $FileCSV -Delimiter ";").HOSTNAMEATUAL) + "." +$Domain
$ServidorNovo = $((Import-Csv $FileCSV -Delimiter ";").HOSTNAMEVM2) + "." +$Domain
$WINS1 = "ag001_ger01"
$WINS2 = "ag001_ger02"
$WINS3 = "ag001_ger03"
$WINS4 = "ag001_ger04"
$WINS5 = "ag001_ger05"
# Configurando primeiro parceiro
Try {
Invoke-Command -ComputerName $ServidorNovo -Credential $CredCliente -ScriptBlock {
netsh.exe wins server add partner server=$using:WINS1 type=1
}
}
Catch {
Write-Host -ForegroundColor Red "Problemas ao configurar servico WINS. Verifique log de sistema."
Write-Host -ForegroundColor Red "Saindo do Script de Migracao..."
Write-Host -ForegroundColor Red "Mensagem de Erro: " $_.Exception.Message
Write-Host -ForegroundColor Red "Item: " $_.Exception.ItemName
Exit
}
Finally {
Write-Host; Write-Host "Primeiro replication partner" $WINS1 "configurado."
}
# Configurando segundo parceiro
Try {
Invoke-Command -ComputerName $ServidorNovo -Credential $CredCliente -ScriptBlock {
netsh.exe wins server add partner server=$using:WINS2 type=1
}
}
Catch {
Write-Host -ForegroundColor Red "Problemas ao configurar servico WINS. Verifique log de sistema."
Write-Host -ForegroundColor Red "Saindo do Script de Migracao..."
Write-Host -ForegroundColor Red "Mensagem de Erro: " $_.Exception.Message
Write-Host -ForegroundColor Red "Item: " $_.Exception.ItemName
Exit
}
Finally {
Write-Host; Write-Host "Segundo replication partner" $WINS2 "configurado."
}
# Configurando terceiro parceiro
Try {
Invoke-Command -ComputerName $ServidorNovo -Credential $CredCliente -ScriptBlock {
netsh.exe wins server add partner server=$using:WINS3 type=1
}
}
Catch {
Write-Host -ForegroundColor Red "Problemas ao configurar servico WINS. Verifique log de sistema."
Write-Host -ForegroundColor Red "Saindo do Script de Migracao..."
Write-Host -ForegroundColor Red "Mensagem de Erro: " $_.Exception.Message
Write-Host -ForegroundColor Red "Item: " $_.Exception.ItemName
Exit
}
Finally {
Write-Host; Write-Host "Terceiro replication partner" $WINS3 "configurado."
}
# Configurando quatro parceiro
Try {
Invoke-Command -ComputerName $ServidorNovo -Credential $CredCliente -ScriptBlock {
netsh.exe wins server add partner server=$using:WINS4 type=1
}
}
Catch {
Write-Host -ForegroundColor Red "Problemas ao configurar servico WINS. Verifique log de sistema."
Write-Host -ForegroundColor Red "Saindo do Script de Migracao..."
Write-Host -ForegroundColor Red "Mensagem de Erro: " $_.Exception.Message
Write-Host -ForegroundColor Red "Item: " $_.Exception.ItemName
Exit
}
Finally {
Write-Host; Write-Host "Quarto replication partner" $WINS4 "configurado."
}
# Configurando quinto parceiro
Try {
Invoke-Command -ComputerName $ServidorNovo -Credential $CredCliente -ScriptBlock {
netsh.exe wins server add partner server=$using:WINS5 type=1
}
}
Catch {
Write-Host -ForegroundColor Red "Problemas ao configurar servico WINS. Verifique log de sistema."
Write-Host -ForegroundColor Red "Saindo do Script de Migracao..."
Write-Host -ForegroundColor Red "Mensagem de Erro: " $_.Exception.Message
Write-Host -ForegroundColor Red "Item: " $_.Exception.ItemName
Exit
}
Finally {
Write-Host; Write-Host "Quinto replication partner" $WINS5 "configurado."
}
Write-Host "Script finalizado."
Write-Host