| 5286 |
dpurdie |
1 |
# This script will:
|
|
|
2 |
# Locate Repos on Master
|
|
|
3 |
# Identify those that have not been converted to VFDS and convert them
|
|
|
4 |
# Identify those that have not been replicated to this machine
|
|
|
5 |
# Create a local Replica
|
|
|
6 |
#
|
|
|
7 |
$MasterServer = "auperasvn01.vix.local"
|
|
|
8 |
$mySID = "S-1-5-21-719430368-289315701-3495892327-45610"
|
|
|
9 |
|
|
|
10 |
# euawsasvn001 S-1-5-21-719430368-289315701-3495892327-34395
|
|
|
11 |
# auawsasvn001 S-1-5-21-719430368-289315701-3495892327-45610
|
|
|
12 |
|
|
|
13 |
$repoList = @()
|
|
|
14 |
Function SetUpRepoSync($repository)
|
|
|
15 |
{
|
|
|
16 |
$repoName = $repository.Name
|
|
|
17 |
Write-Host "Processing: ", $repoName
|
|
|
18 |
$ab = Get-WmiObject -Namespace "root\VisualSVN" -ClassName VisualSVN_Repository | where { $_.name -eq $repoName }
|
|
|
19 |
if ( $ab )
|
|
|
20 |
{
|
|
|
21 |
Write-Host ("Local Repo found - not processed")
|
|
|
22 |
}
|
|
|
23 |
else
|
|
|
24 |
{
|
|
|
25 |
Write-Host ("Sync Repo:", $repoName)
|
|
|
26 |
$settings = Invoke-CimMethod $repository -MethodName GetReplicationSettings
|
|
|
27 |
#$settings
|
|
|
28 |
|
|
|
29 |
$settings.Enabled = $true
|
|
|
30 |
$acc1 = New-CimInstance -ClientOnly -Namespace root/visualsvn -ClassName VisualSVN_WindowsAccount -Property @{SID = $mySID }
|
|
|
31 |
|
|
|
32 |
[System.Collections.ArrayList] $replicators = $settings.Replicators
|
|
|
33 |
$replicators.Add($acc1)
|
|
|
34 |
[CimInstance[]] $newReplicators = $replicators.ToArray()
|
|
|
35 |
|
|
|
36 |
Invoke-CimMethod $repository -MethodName SetReplicationSettings -Arguments @{Enabled= $settings.Enabled; Replicators = $newReplicators }
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
Invoke-CimMethod -Namespace root\VisualSVN -ClassName VisualSVN_Repository -MethodName CreateVdfsSlave -Arguments @{ Name = $repoName; MasterServer = $MasterServer; MasterRepository = $repoName }
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
Function ConvertRepo($repository)
|
|
|
44 |
{
|
|
|
45 |
$repoName = $repository.Name
|
|
|
46 |
Write-Host "Convert Repo: ", $repoName
|
|
|
47 |
$rv = Invoke-CimMethod $repository -MethodName ConvertToVdfs
|
|
|
48 |
$rv
|
|
|
49 |
|
|
|
50 |
if ( $rv.ReturnValue -ne "0" )
|
|
|
51 |
{
|
|
|
52 |
Write-Host "Error converting Repo:", $repoName
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
Get-CimInstance -ComputerName $MasterServer -Namespace "root\VisualSVN" -ClassName VisualSVN_Repository | ForEach-Object {
|
|
|
58 |
Write-Host "Name", $_.name, "Type:", $_.Type
|
|
|
59 |
|
|
|
60 |
# Only process Master VFDS repos
|
|
|
61 |
# Type of repository: 0 - FSFS, 1 - VDFS (master), 2 - VDFS (slave)
|
|
|
62 |
# - Ignore Slaves
|
|
|
63 |
# - Ignore non VFDS repos
|
|
|
64 |
|
|
|
65 |
if ( $_.type -eq "1" )
|
|
|
66 |
{
|
|
|
67 |
Write-Host "Will be processed", $_.name
|
|
|
68 |
SetUpRepoSync $_
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
if ( $_.type -eq "0" )
|
|
|
72 |
{
|
|
|
73 |
Write-Host "Will be Converted", $_.name
|
|
|
74 |
ConvertRepo $_
|
|
|
75 |
#exit
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
|