-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMove-WacDatabase.ps1
More file actions
27 lines (24 loc) · 1.47 KB
/
Move-WacDatabase.ps1
File metadata and controls
27 lines (24 loc) · 1.47 KB
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
$WacSourceServer = "azs-mgmt"
$WacDestinServer = "azs-wac-demo"
#====================
$RootFolder = "C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\"
$RootSme = "ServerManagementExperience"
$SmeServiceName = "ServerManagementGateway"
$SessionSrc = New-PSSession -ComputerName $WacSourceServer
$SessionDst = New-PSSession -ComputerName $WacDestinServer
#Compress Zip-Files on both nodes
Invoke-Command -Session $SessionSrc -ScriptBlock {
Stop-Service -Name $using:SmeServiceName -Force
Compress-Archive -Path ($using:RootFolder + $using:RootSme) -DestinationPath "$env:USERPROFILE\Desktop\ServerManagementExperience.zip"
$SessionDst = New-PSSession -ComputerName $using:WacDestinServer -Credential (Get-Credential)
Copy-Item -ToSession $SessionDst -Path "$env:USERPROFILE\Desktop\ServerManagementExperience.zip" -Destination "$env:USERPROFILE\Desktop\ServerManagementExperience.zip"
}
Invoke-Command -Session $SessionDst -ArgumentList @{} -ScriptBlock {
Stop-Service -Name $using:SmeServiceName -Force
Start-Sleep -Seconds 5
Compress-Archive -Path ($using:RootFolder + $using:RootSme) -DestinationPath "$env:USERPROFILE\Desktop\ServerManagementExperience_Backup.zip" -Force
Remove-Item -Path ($using:RootFolder + $using:RootSme) -Confirm:$false -Recurse -Force
Expand-Archive -Path "$env:USERPROFILE\Desktop\ServerManagementExperience.zip" -DestinationPath $using:RootFolder -Force
Start-Service -Name $using:SmeServiceName
}
#====================