-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-DAContainerSize.ps1
139 lines (114 loc) · 3.79 KB
/
Get-DAContainerSize.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<#
.SYNOPSIS
Script is used to report on the number of Sites per DocAve container
.DESCRIPTION
This script will be used to check the total amount of Site Collections within a container.
In large environments we recommend to not put in more than 15.000 Site Collections into
one container to avoid performance problems.
.EXAMPLE
$cred = get-Credential
Get-DAContainerSize -ControlHost "DocAveServer" -Username $cred.username -Password $cred.password
.COMPONENT
AvePoint Cloud Records
#>
[CmdletBinding(DefaultParameterSetName='Parameter Set 1',
SupportsShouldProcess=$true,
PositionalBinding=$false,
HelpUri = 'http://www.avepoint.com/',
ConfirmImpact='Medium')]
param (
#DocAve Control Host Server hostname
[Parameter(Mandatory=$true)]
[string]
$ControlHost,
#DocAve Server username with administrative permissions
[Parameter(Mandatory=$true)]
[string]
$UserName,
#DocAve Server password with administrative permissions
[Parameter(Mandatory=$true)]
[SecureString]
$Password,
#DocAve Control Server Port
[Parameter(Mandatory=$false)]
[string]
$ControlPort = "14000",
#Define maximum number of Site Collections in container
[Parameter(Mandatory=$false)]
[int]
$ContainerSize = 15000,
# Optional - Log Directory
[Parameter(Mandatory=$false)]
[string]
$LogDir = 'Logs'
)
# V 1.0 06/22/2021 Initial Release
$currentTime=Get-Date -Format 'yyyy-MM-dd_HH-mm-ss';
$LogFileName = "Get-DAContainerSize"+$currentTime+".log";
$logName = Join-Path -Path $LogDir -ChildPath $LogFileName;
# Requires DocAve PowerShell to be installed on the systems running this script
# Import DocAve Module / PowerShell
import-module DocAveModule -ErrorAction Stop
function Main {
[CmdletBinding(DefaultParameterSetName='Parameter Set 1',
SupportsShouldProcess=$true,
PositionalBinding=$false,
HelpUri = 'http://www.avepoint.com.com/',
ConfirmImpact='Medium')]
Param ()
begin {
CreateLogPath;
OutputToHostAndLog "---- Start script ----"
}
process {
if ($pscmdlet.ShouldProcess("Target", "Operation")) {
### Login to the control service
try {
Login-DAManager -ControlHost $ControlHost -ControlPort $ControlPort -Username $UserName -Password $Password
}
catch {
OutputToHostAndLog "Login to DocAve failed $($Error[0])"
break
}
try {
$Containers = Get-DASPOnlineSitesGroup
OutputToHostAndLog 'Load containers'
OutputToHostAndLog "Container count: [$($Containers.Count)] "
foreach ($Container in $Containers) {
If($Container.Sites.Count -le $ContainerSize)
{
OutputToHostAndLog "Container OK: $($Container.Name) has $($Container.Sites.Count)"
} else {
OutputToHostAndLog "Container FAIL: $($Container.Name) has $($Container.Sites.Count)"
}
}
}
catch {
OutputToHostAndLog "Could not get containers"
break
}
}
}
end {
OutputToHostAndLog "---- End script ----"
}
}
function CreateLogPath()
{
if(!(Test-Path $script:LogDir))
{
mkdir $script:LogDir | Out-Null
}
}
function OutputToHostAndLog($str)
{
Write-Host $str;
OutputToLog $str;
}
function OutputToLog($str)
{
$dateTime=Get-Date -Format 'yyyy-MM-dd HH:mm:ss';
$message=$dateTime+" "+$str;
$message | Out-File -Append -filepath $logName;
}
Main