This repository was archived by the owner on Apr 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPWakeUp.ps1
More file actions
67 lines (65 loc) · 4.43 KB
/
Copy pathSPWakeUp.ps1
File metadata and controls
67 lines (65 loc) · 4.43 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
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
function get-webpage([string]$url,[System.Net.NetworkCredential]$cred=$null)
{
$error = $false
$webRequest = [System.Net.HttpWebRequest]::Create($url)
$webRequest.Timeout = 300000
if($cred -eq $null)
{
$webRequest.Credentials = [system.Net.CredentialCache]::DefaultCredentials
}
try {
$res = $webRequest.getresponse()
}catch{
$error = $true
}
}
Function Load-SharePoint-Powershell
{
If ((Get-PsSnapin |?{$_.Name -eq "Microsoft.SharePoint.PowerShell"})-eq $null)
{
Write-Host -ForegroundColor White " - Loading SharePoint Powershell Snapin"
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction Stop
}
}
Load-SharePoint-Powershell
$webapplications = Get-SPWebApplication
$AllSites = Get-SPSite -limit all
$Array = @()
$i=0
foreach ($wa in $webapplications)
{
foreach ($windowsauth in $wa.AlternateUrls)
{
$authenticationprovider= Get-SPAuthenticationProvider -webapplication $wa -zone $windowsauth.Zone
If ($authenticationprovider.UseWindowsIntegratedAuthentication)
{
$accessableURL = $windowsauth.IncomingUrl
}
}
if (!$AccessableURL) {$accessableURL = $wa.url -replace ".$"}
foreach ($site in $AllSites)
{
if ($Site.Url -and $Site.Url+"/" -match $wa.url)
{
$subsites = Get-SPSite $Site.Url | Get-SPWeb -Limit All
Foreach ($subsite in $subsites)
{
$i++
Write-Progress -activity "Looking up all sites" -status "Please Wait..." -PercentComplete (($i / 500) * 100)
$PlainWaUrl = $wa.Url -replace ".$"
$WakeUpSite = $Subsite.Url.replace($PlainWaUrl, $accessableURL)
$Array = $Array + $WakeUpSite
#$html=get-webpage -url "$WakeUpSite" -cred $cred;
if ($i -eq 500){$i=0}
}
Remove-Variable i
}
}
Remove-Variable accessableURL
}
Foreach ($Website in $Array)
{
$i++
Write-Progress -activity "Waking up sites" -status "Waking: $Website" -PercentComplete (($i / $Array.Count) * 100)
$html=get-webpage -url "$Website" -cred $cred;
}