-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-SPFarmInfo.ps1
2486 lines (2310 loc) · 106 KB
/
Get-SPFarmInfo.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<# =====================================================================
## Title : Get-SPFarmInfo.ps1
## Description : This script will collect information regarding the Farm, Search, and the SSA's in the Farm.
## Contributors: Anthony Casillas | Brian Pendergrass | Josh Roark | PG
## Date : 04-06-2021
## Input :
## Output :
## Usage : .\Get-SPFarmInfo.ps1
## Notes : Scroll to bottom for change notes...
## Tag : Search, Sharepoint, Powershell
## =====================================================================
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
Write-Output "This script can take several mins to run."
Write-Host ""
Write-Output "If you have a single SSA or no SSA in your Farm, this will move along with no interaction"
Write-Host ""
Write-Output "If you have more than 1 SSA, then you will be prompted to select the SSA we will be focused on"
Write-Host ""
$timestamp = $(Get-Date -format "MM-dd-yyyy")
$output = Read-Host "Enter a location for the output file (For Example: C:\Temp)"
$outputfilePrefix = $output + "\SPFarmInfo_"
$global:farm = Get-SPFarm
$global:servers = Get-SPServer | Sort-Object -Property DisplayName, Role
$global:serviceInstances = Get-SPServiceInstance -All | Sort-Object -Property Server, TypeName
$spProduct = Get-SPProduct
Function WriteErrorAndExit($errorText)
{
Write-Host -BackgroundColor Red -ForegroundColor Black $errorText
Write-Host -BackgroundColor Red -ForegroundColor Black "Aborting script"
exit
}
#-----------------------------------------------
# GetSSA: Get SSA reference
#-----------------------------------------------
function GetSSA
{
$ssas = @(Get-SPEnterpriseSearchServiceApplication)
if($ssas.Length -eq 0)
{
Write-Host ""
Write-Host "There is no SSA in this farm. We will still collect some basic information"
Write-Host ""
return NoSSA
}
elseif($ssas.Count -eq 1)
{
$global:ssa = $ssas[0]
}
else
{
$menu = @{}
for($i=1;$i -le $ssas.count; $i++)
{
Write-Host "$i $($ssas[$i-1].name)"
$menu.Add($i,($ssas[$i-1].name))
}
""
$ans = Read-Host 'Enter SSA selection ( pick the number to the left of the SSA Name )' -ErrorAction SilentlyContinue
$ans = $ans -as [int]
if($null -eq $ans -or ($ans.gettype()).Name -eq "String")
{
Write-Warning ("-- Your selection must be an Integer value. Please enter the number to the left of the SSA Name as your selection.")
return GetSSA
}
else
{
$selection = $menu.Item($ans)
$global:ssa = Get-SPEnterpriseSearchServiceApplication $selection
}
}
if ($global:ssa.Status -ne "Online")
{
$ssaStat = $global:ssa.Status
Write-Warning ("Expected SSA to have status 'Online', found status: $ssaStat")
}
return $global:ssa
}
#-----------------------------------------------
# GetFarmBuild: Get Farm Build\Version
#-----------------------------------------------
Function GetFarmBuild()
{
Write-Host "Getting SP Farm Build"
""
"[ SharePoint Farm Build: " + $farm.BuildVersion + " ]"
""
}
#-----------------------------------------------
## GetServersInFarm
#-----------------------------------------------
function GetServersInFarm()
{
Write-Host "Getting Servers in the Farm"
""
"#########################################################################################"
" Servers in the Farm "
"#########################################################################################"
foreach($svr in $global:servers)
{
if($svr.Role -ne "Invalid")
{
$productStatus = $null
$productStatus = $spProduct.GetStatus($svr.DisplayName)
$timeZone = $(Get-WMIObject -Class Win32_TimeZone -Computer $svr.address -ErrorAction SilentlyContinue).Description
$svr.DisplayName + " || " + $svr.Id + " || " + $svr.Role + " || " + $svr.Status + " || " + $productStatus + " || " + $timeZone
}
else
{
$timeZone = $(Get-WMIObject -Class Win32_TimeZone -Computer $svr.address -ErrorAction SilentlyContinue).Description
$svr.DisplayName + " || " + $svr.Id + " || " + $svr.Role + " || " + $svr.Status + " || " + $timeZone
}
}
""
}
#-----------------------------------------------
# Get Service Instances
#-----------------------------------------------
function GetServiceInstances()
{
Write-Host "Getting Service Instances Information"
""
"#########################################################################################"
" What Service Instances are running and on what Server? "
"#########################################################################################"
""
$serviceInstances = $global:serviceInstances | Where-Object{$_.Status -ne "Disabled"}
foreach ($si in $serviceInstances)
{
$si.Server.Address + " -- " + $si.TypeName + " -- " + $si.Status
}
""
}
#-----------------------------------------------
## GetServiceApplications ##
#-----------------------------------------------
function GetServiceApplications()
{
Write-Host "Getting Service Application Information that are in a state other than 'Disabled'"
""
"#########################################################################################"
" Service Application Info "
"#########################################################################################"
""
$serviceApps = Get-SPServiceApplication | ?{$_.Status -ne "Disabled"}
"DisplayName" + " -- " + "Id" + " -- " + "Status"
""
foreach ($spserviceApp in $serviceApps)
{
$spserviceApp.DisplayName + " -- " + $spserviceApp.Id.ToString() + " -- " + $spserviceApp.Status
}
}
#-----------------------------------------------
## CheckTimerServiceInstances ##
#-----------------------------------------------
function CheckTimerServiceInstances()
{
Write-Host "Checking Timer Service Instances at the Farm Level. Disabled Service Instances can prevent timer jobs from executing...`n"
""
"#########################################################################################"
" 'Farm Level Timer Service Instances' Check "
"#########################################################################################"
$farmTimers = $farm.TimerService.Instances
"Server" + " -- " + "Status" + " -- " + "AllowServiceJobs" + " -- " + "AllowContentDBJobs"
""
foreach ($ft in $farmTimers)
{
$ft.Server.Name.ToString() + " -- " + $ft.status + " -- " + $ft.AllowServiceJobs + " -- " + $ft.AllowContentDatabaseJobs
}
$disabledTimers = $farm.TimerService.Instances | where {$_.Status -ne "Online"}
if ($disabledTimers -ne $null)
{
foreach ($timer in $disabledTimers)
{
Write-Host -ForegroundColor Red " Timer service instance on server " $timer.Server.Name " is NOT Online. Current status:" $timer.Status
Write-Host -ForegroundColor Green " Attempting to set the status of the service instance to online..."
$timer.Status = [Microsoft.SharePoint.Administration.SPObjectStatus]::Online
$timer.Update()
""
$timer.Server.Name + " Timer Instance was Disabled, but is now " + $timer.Status + ". You MUST now go restart the SharePoint timer service on server " + $timer.Server.Name
write-host -ForegroundColor Yellow " You MUST now go restart the SharePoint timer service on server " $timer.Server.Name
}
}
else
{
Write-Host (" All Timer Service Instances in the farm are online. No problems found!") -ForegroundColor Green
}
}
function CheckAdminServiceInstance()
{
Write-Host ""
Write-host "Now checking SharePoint ADMINISTRATION Service Instances...`n"
""
"#########################################################################################"
" 'Administration Service Instances' - Check "
"#########################################################################################"
$adminServiceInstances = $farm.servers.serviceinstances | ? {$_.TypeName -eq "Microsoft SharePoint Foundation Administration"}
"Server" + " -- " + "Status" + " -- " + "Id"
""
$adminSiAllGood = $true
foreach($adminSi in $adminServiceInstances)
{
$adminSi.Server.Name.ToString() + " -- " + $adminSi.Status + " -- " + $adminSi.Id
if($adminSi.Status -eq "Disabled")
{
Write-Host -ForegroundColor Red " Administration Service Instance on server " $adminSi.Server.Name " is NOT Online. Current status:" $adminSi.Status
Write-Host -ForegroundColor Green " Attempting to set the status of the service instance to online..."
$adminSi.Status = [Microsoft.SharePoint.Administration.SPObjectStatus]::Online
$adminSi.Update()
""
" ---Administration Service Instance was Disabled, but is now " + $adminSi.Status + ". You MUST now go restart the SharePoint Administration service (in services.msc) on server " + $adminSi.Server.Name
""
write-host -ForegroundColor Yellow " You MUST now go restart the SharePoint Administration service (in services.msc) on server " $adminSi.Server.Name
$adminSiAllGood = $false
}
}
if($adminSiAllGood)
{
Write-Host " All Administration Service Instances in the farm are online. No problems found with SPAdminV4" -ForegroundColor Green
}
}
#End Script
#-----------------------------------------------
## Check TimerJobHistory table size ##
#-----------------------------------------------
function CheckTimerJobHistory()
{
Write-Host ""
Write-Host "Checking the size of the 'timerjobhistory' table... "
Write-Host ""
Write-Host " --If there are millions of rows in this table, this can prevent jobs from running or cause timer jobs to time out. "
Write-Host " --- As of April 2018 CU, for SP 2013 and 2016, there were changes implemented to limit the timer job history to 3 days"
Write-Host " ---- https://blogs.technet.microsoft.com/stefan_gossner/2018/04/12/changes-in-the-timerjobhistory-table-maintenance-introduced-in-april-2018-cu-for-sharepoint-2013/"
Write-Host ""
""
"#########################################################################################"
" TimerJobHistory table "
"#########################################################################################"
$conn = New-Object System.Data.SqlClient.SqlConnection
$cmd = New-Object System.Data.SqlClient.SqlCommand
$configDb = Get-SPDatabase | ?{$_.TypeName -match "Configuration Database"}
$connectionString = $configDb.DatabaseConnectionString
$conn.ConnectionString = $connectionString
$conn.Open()
$cmd.connection = $conn
#Write-Host "Issuing Query on: " $configDb.Name
#""
$cmd.CommandText = "select COUNT(*) from TimerJobHistory (nolock)"
$rows = $cmd.ExecuteReader()
if($rows.HasRows -eq $true)
{
while($rows.Read())
{
Write-Host("TimerJobHistory table contains: " + $rows[0] + " rows")
Write-Host ""
""
"TimerJobHistory table contains: " + $rows[0] + " rows"
""
}
}
$rows.Close()
$conn.Close()
}
#-----------------------------------------------
## Check for Farm - SiteSubscriptions ##
#-----------------------------------------------
function CheckFarmSiteSubscriptions
{
Write-Host "Checking for Site Subscription IDs in the farm."
Write-Host ""
if($global:farm.SiteSubscriptions -ne $null)
{
Write-Host(" We have detected potential SiteSubscriptions in this farm. If your site contains subscriptionId's and the SSA is not not Partitioned (' This is not common' ), then search results and usage\analytics can be impacted by this.") -ForegroundColor Cyan
Write-Host ""
""
"#########################################################################################"
" Site Subscription Info "
"#########################################################################################"
""
" We have detected SiteSubscriptions in this farm. If your site contains subscriptionId's and the SSA is not Partitioned (' This is not common' ), then search results and usage\analytics can be impacted by this. "
" Recommended that you execute the following to output those Subscriptions"
""
" get-spsite -limit All | Select Url, SiteSubscription "
""
" If any URL reports a subscription ID, these sites could fail to return search results or usage\analytics reports "
#foreach($siteSubscription in $global:farm.SiteSubscriptions)
#{
# if($siteSubscription.Sites -ne $null)
# {
# foreach($spSite in $siteSubscription.Sites)
# {
# $spSite.Url + " -- " + $siteSubscription.Id
# }
# }
#}
}
else
{
Write-Host " -- No Site Subscriptions detected"
"#########################################################################################"
" Site Subscription Info "
"#########################################################################################"
""
" No Site Subscriptions detected"
}
}
#-----------------------------------------------
# SSA Related Timer Jobs
#-----------------------------------------------
function GetSSARelatedTimerJobs
{
Write-Host "Checking for SSA related timer jobs"
""
"#########################################################################################"
" SSA Related Timer Jobs "
"#########################################################################################"
$ssaJobs = "Application " + $global:ssa.Id
Get-SPTimerJob | ?{$_.Name -match $ssaJobs} | Select Name
""
$tjText = @"
- SSAs should have several timer jobs associated with them
-- SP 2013 should have 7 timer jobs
-- SP 2016 should have 8 timer jobs
-- SP 2019 should have 9 jobs
- If there are any less than these ( respective of the SP Version), then the easiest course of action to get those timer jobs back in place would be to run: ( insert correct SSA name and remove space between $ and ssa )
-- $ ssa = Get-SPEnterpriseSearchServiceApplication <your ssa name here>
-- $ ssa.Status = "Disabled"
-- $ ssa.Update()
-- $ ssa.Provision()
"@
$tjText
Write-Host ("$tjText") -ForegroundColor Gray
Write-Host ""
}
#-----------------------------------------------
# SSA Full Object
#-----------------------------------------------
function GetSSAFullObject()
{
Write-Host "Collecting some SSA object info.."
Write-Host ""
""
$fullSsaObject = New-Object PSObject
"#########################################################################################"
" " + $global:ssa.Name + " Object "
"#########################################################################################"
if($global:ssa.NeedsUpgradeIncludeChildren -eq $true -or $global:ssa.NeedsUpgrade -eq $true)
{
Write-Warning (" We have detected that your 'SSA' objects need to be upgraded. In order to perform this action, please run the following command: ")
Write-Host ""
Write-Host (" --- 'Upgrade-SPEnterpriseSearchServiceApplication <your SSA Name>' ") -ForegroundColor Gray
Write-Host ""
""
"WARNING: We have detected that your 'SSA' objects need to be upgraded. In order to perform this action, please run the following command: "
""
" --- 'Upgrade-SPEnterpriseSearchServiceApplication <your SSA Name>' "
""
}
$fullSsaObject | Add-Member DisplayName $global:ssa.DisplayName
$fullSsaObject | Add-Member Name $global:ssa.Name
$fullSsaObject | Add-Member Id $global:ssa.Id
$fullSsaObject | Add-Member ApplicationName $global:ssa.ApplicationName
$fullSsaObject | Add-Member CloudIndex $global:ssa.CloudIndex
$fullSsaObject | Add-Member ServiceName $global:ssa.ServiceName
$fullSsaObject | Add-Member TypeName $global:ssa.TypeName
$fullSsaObject | Add-Member DefaultSearchProvider $global:ssa.DefaultSearchProvider
$fullSsaObject | Add-Member LocationConfigurations $global:ssa.LocationConfigurations
$fullSsaObject | Add-Member AlertNotificationFormat $global:ssa.AlertNotificationFormat
$fullSsaObject | Add-Member QueryLoggingEnabled $global:ssa.QueryLoggingEnabled
$fullSsaObject | Add-Member QuerySuggestionsEnabled $global:ssa.QuerySuggestionsEnabled
$fullSsaObject | Add-Member PersonalQuerySuggestionsEnabled $global:ssa.PersonalQuerySuggestionsEnabled
$fullSsaObject | Add-Member SearchCenterUrl $global:ssa.SearchCenterUrl
$fullSsaObject | Add-Member SharedSearchBoxSettings $global:ssa.SharedSearchBoxSettings
$fullSsaObject | Add-Member UrlZoneOverride $global:ssa.UrlZoneOverride
$fullSsaObject | Add-Member HeadQueryFrequencyThreshold $global:ssa.HeadQueryFrequencyThreshold
$fullSsaObject | Add-Member NameNormalizationEnabled $global:ssa.NameNormalizationEnabled
$fullSsaObject | Add-Member NameNormalizationPreferredNamePID $global:ssa.NameNormalizationPreferredNamePID
$fullSsaObject | Add-Member QueryLogSettings $global:ssa.QueryLogSettings
$fullSsaObject | Add-Member DiacriticSensitive $global:ssa.DiacriticSensitive
$fullSsaObject | Add-Member VerboseQueryMonitoring $global:ssa.VerboseQueryMonitoring
$fullSsaObject | Add-Member VerboseSubFlowTiming $global:ssa.VerboseSubFlowTiming
$fullSsaObject | Add-Member SearchAdminDatabase $global:ssa.SearchAdminDatabase.Name
$fullSsaObject | Add-Member CrawlStores $global:ssa.CrawlStores
$fullSsaObject | Add-Member LinksStores $global:ssa.LinksStores
$fullSsaObject | Add-Member AnalyticsReportingDatabases $global:ssa.AnalyticsReportingDatabases
$fullSsaObject | Add-Member AnalyticsReportingStore $global:ssa.AnalyticsReportingStore
$fullSsaObject | Add-Member CrawlLogCleanupIntervalInDays $global:ssa.CrawlLogCleanupIntervalInDays
$fullSsaObject | Add-Member DefaultQueryTimeout $global:ssa.DefaultQueryTimeout
$fullSsaObject | Add-Member MaxQueryTimeout $global:ssa.MaxQueryTimeout
$fullSsaObject | Add-Member MaxKeywordQueryTextLength $global:ssa.MaxKeywordQueryTextLength
$fullSsaObject | Add-Member DiscoveryMaxKeywordQueryTextLength $global:ssa.DiscoveryMaxKeywordQueryTextLength
$fullSsaObject | Add-Member DiscoveryMaxRowLimit $global:ssa.DiscoveryMaxRowLimit
$fullSsaObject | Add-Member MaxRowLimit $global:ssa.MaxRowLimit
$fullSsaObject | Add-Member MaxRankingModels $global:ssa.MaxRankingModels
$fullSsaObject | Add-Member AllowQueryDebugMode $global:ssa.AllowQueryDebugMode
$fullSsaObject | Add-Member AllowPartialResults $global:ssa.AllowPartialResults
$fullSsaObject | Add-Member AllowedMaxRowLimitSp14 $global:ssa.AllowedMaxRowLimitSp14
$fullSsaObject | Add-Member AlertsEnabled $global:ssa.AlertsEnabled
$fullSsaObject | Add-Member FarmIdsForAlerts $global:ssa.FarmIdsForAlerts
$fullSsaObject | Add-Member AlertNotificationQuota $global:ssa.AlertNotificationQuota
$fullSsaObject | Add-Member ResetAndEnableAlerts $global:ssa.ResetAndEnableAlerts
$fullSsaObject | Add-Member SystemManagerLocations $global:ssa.SystemManagerLocations
$fullSsaObject | Add-Member ApplicationClassId $global:ssa.ApplicationClassId
$fullSsaObject | Add-Member ManageLink $global:ssa.ManageLink
$fullSsaObject | Add-Member PropertiesLink $global:ssa.PropertiesLink
$fullSsaObject | Add-Member MinimumReadyQueryComponentsPerPartition $global:ssa.MinimumReadyQueryComponentsPerPartition
$fullSsaObject | Add-Member TimeBeforeAbandoningQueryComponent $global:ssa.TimeBeforeAbandoningQueryComponent
$fullSsaObject | Add-Member EnableIMS $global:ssa.EnableIMS
$fullSsaObject | Add-Member FASTAdminProxy $global:ssa.FASTAdminProxy
$fullSsaObject | Add-Member UseSimpleSchemaUI $global:ssa.UseSimpleSchemaUI
$fullSsaObject | Add-Member LatencyBasedQueryThrottling $global:ssa.LatencyBasedQueryThrottling
$fullSsaObject | Add-Member CpuBasedQueryThrottling $global:ssa.CpuBasedQueryThrottling
$fullSsaObject | Add-Member LoadBasedQueryThrottling $global:ssa.LoadBasedQueryThrottling
$fullSsaObject | Add-Member IisVirtualDirectoryPath $global:ssa.IisVirtualDirectoryPath
$fullSsaObject | Add-Member ApplicationPool $global:ssa.ApplicationPool.DisplayName
$fullSsaObject | Add-Member PermissionsLink $global:ssa.PermissionsLink
$fullSsaObject | Add-Member DefaultEndpoint $global:ssa.DefaultEndpoint
$fullSsaObject | Add-Member Uri $global:ssa.Uri
$fullSsaObject | Add-Member Shared $global:ssa.Shared
$fullSsaObject | Add-Member Comments $global:ssa.Comments
$fullSsaObject | Add-Member TermsOfServiceUri $global:ssa.TermsOfServiceUri
$fullSsaObject | Add-Member Service $global:ssa.Service
$fullSsaObject | Add-Member ServiceInstances $global:ssa.ServiceInstances
$fullSsaObject | Add-Member ServiceApplicationProxyGroup $global:ssa.ServiceApplicationProxyGroup
$fullSsaObject | Add-Member ApplicationVersion $global:ssa.ApplicationVersion
$fullSsaObject | Add-Member CanUpgrade $global:ssa.CanUpgrade
$fullSsaObject | Add-Member IsBackwardsCompatible $global:ssa.IsBackwardsCompatible
$fullSsaObject | Add-Member NeedsUpgradeIncludeChildren $global:ssa.NeedsUpgradeIncludeChildren
$fullSsaObject | Add-Member NeedsUpgrade $global:ssa.NeedsUpgrade
$fullSsaObject | Add-Member UpgradeContext $global:ssa.UpgradeContext
$fullSsaObject | Add-Member Status $global:ssa.Status
$fullSsaObject | Add-Member Parent $global:ssa.Parent
$fullSsaObject | Add-Member Version $global:ssa.Version
$fullSsaObject | Add-Member Farm $global:ssa.Farm
$fullSsaObject | Add-Member UpgradedPersistedProperties $global:ssa.UpgradedPersistedProperties
$fullSsaObject | Add-Member CanSelectForBackup $global:ssa.CanSelectForBackup
$fullSsaObject | Add-Member DiskSizeRequired $global:ssa.DiskSizeRequired
$fullSsaObject | Add-Member CanSelectForRestore $global:ssa.CanSelectForRestore
$fullSsaObject | Add-Member CanRenameOnRestore $global:ssa.CanRenameOnRestore
$fullSsaObject | fl
}
#---------------------------------------------------
# Check if the SSA and its Proxy is Partitioned
#----------------------------------------------------
#---------------------------------------------------
# Check if the SSA and its Proxy is Partitioned
#----------------------------------------------------
function checkIfPartitioned
{
""
""
"#########################################################################################"
" Is SSA Proxy and\or SSA 'Partitioned' ?"
"#########################################################################################"
""
Write-host ""
Write-Host "Checking the 'Properties' property of the SSA and Search Proxy"
#Write-Host "Checking to see if the SSA Proxy.Properties is UnPartitioned. If it is partitioned ( this would have been done at creation time ), this can break contextual searches, especially on Web Apps that have been extended to another zone. URLMapping fails to happen if the Proxy is partitioned"
#Write-Host "Also displaying the SSA's Properties to see if 'UnPartitioned'. If the SSA is partitioned, this can impact search results and analytics, if sites have SiteSubscriptions assigned ( this is not typical) "
Write-host ""
"By default, the SSA and SSA Proxy should have a value of 'UnPartitioned'. Anything other than that value, would indicate that the SSA would want to treat its 'data' as multi-tenant content ( like Office365 where it would partition tenants information so one tenant cannot see anothers ). "
"If you 'Partition' the SSA, and you do **not** have SiteSubscriptions, set up (This is not common, and siteSubsctiptions are no longer supported in SP 2019), then search and analytics can be impacted."
"If your SSA is 'UnPartitioned' and you do have SiteSubscriptions setup ( again, not common ) search results and analytics may not work as expected"
""
"If the SSA Proxy is partitioned ( this would have been done at creation time ), URLMapping does not take place and will break contextual searches on Web Apps that have been extended to another zone"
"If the Proxy is 'partitioned', you can easily resolve this by deleting the proxy within 'CA > Manage Service Apps' and then recreate it with something like: "
""
" 'New-SPEnterpriseSearchServiceApplicationProxy -SearchApplication 'SSA NAME' -Name 'Proxy Name' "
""
"Simply Put... your SSA and SSA Proxy should not have anything other than 'UnPartitioned' "
""
""
$proxyAppGuid = $global:ssa.id -replace "-", ""
$ssaProxy = Get-SPEnterpriseSearchServiceApplicationProxy | ?{$_.ServiceEndpointuri -like ("*$proxyAppGuid*")}
$ssaProxyPropertiesProperty = $ssaProxy.Properties["Microsoft.Office.Server.Utilities.SPPartitionOptions"]
$ssaPropertiesProperty = $global:ssa.Properties["Microsoft.Office.Server.Utilities.SPPartitionOptions"]
if($ssaProxyPropertiesProperty -ne "UnPartitioned")
{
Write-Host -ForegroundColor Yellow " The Search Proxy for this SSA is not set to 'UnPartitioned'. If the proxy is partitioned ( this would have been done at creation time ), URLMapping does not take place and will break contextual searches on Web Apps that have been extended to another zone"
Write-Host ""
" Property for 'searchProxy.Properties' is set to: '$ssaProxyPropertiesProperty' ( This can impact queries on extended zone URLs, among other search functions) "
}
else
{
Write-Host -ForegroundColor Green " Your Search Proxy 'Properties' are set to expected values."
Write-Host ""
""
" Your Search Proxy 'Properties' are set to expected values."
""
}
if($ssaPropertiesProperty -ne "UnPartitioned")
{
Write-Host -ForegroundColor Yellow " The SSA is not set to 'UnPartitioned'. If your SSA is 'Partitioned' and you do not have SiteSubscriptions set up (This is not common, and no longer supported in SP 2019), then search and analytics can be impacted by this."
Write-Host ""
" Property for 'ssa.Properties' is set to: '$ssaPropertiesProperty' ( this can impact search\analytics) "
}
else
{
Write-Host -ForegroundColor Green " Your SSA 'Properties' are set to expected values."
Write-Host ""
""
" Your SSA 'Properties' are set to expected values."
""
}
}
#-----------------------------------------------
# Legacy Admin
#-----------------------------------------------
function GetSSALegacyAdminComponent()
{
Write-Host "Getting Legacy Admin Component Info"
""
" -------------------------------------------------------------------"
" Legacy Admin Component"
" -------------------------------------------------------------------"
""
$global:ssa.AdminComponent
""
" -------------------------------------------------------------------"
}
#-----------------------------------------------------------
## Check MSSConfiguration table for broken CPC ##
#-----------------------------------------------------------
function CheckCpcFromMssConfiguration
{
Write-Host "Checking the Content Distributor Property from SSA Admin DB. If the property contains anything that reflects 'net.tcp:///' instead of 'net.tcp://<servername>/, then your crawls will hang. In the ULS, on the crawl servers, you should see this HResult being thrown: 0x80131537"
Write-host ""
$conn = New-Object System.Data.SqlClient.SqlConnection
$cmd = New-Object System.Data.SqlClient.SqlCommand
$adminDb = Get-SPDatabase | ?{$_.Name -eq $ssa.SearchAdminDatabase.Name}
$connectionString = $adminDb.DatabaseConnectionString
$conn.ConnectionString = $connectionString
$conn.Open()
$cmd.connection = $conn
#Write-Host "Issuing Query on: " $configDb.Name
#""
$cmd.CommandText = "select top 5 Value from MSSConfiguration where name like '%FastConnector:ContentDistributor'"
$rows = $cmd.ExecuteReader()
if($rows.HasRows -eq $true)
{
while($rows.Read())
{
" -------------------------------------------------------------------"
" Content Distributor Property"
" -------------------------------------------------------------------"
""
"Checking the Content Distributor Property from SSA Admin DB. If the property contains anything that reflects 'net.tcp:///' instead of 'net.tcp://<servername>/, then your crawls will hang. In the ULS, on the crawl servers, you should see this HResult being thrown: 0x80131537"
""
Write-Host(" ContentDistributor Property is: ") -ForegroundColor Gray; ([System.Environment]::NewLine); $rows[0]
Write-Host " " $rows[0] -ForegroundColor Gray
Write-Host ""
""
""
}
}
$rows.Close()
$conn.Close()
}
#-----------------------------------------------
# Search Topology
#-----------------------------------------------
function GetSearchTopo()
{
Write-Host "Getting Search Topology Info"
""
$activeTopo = Get-SPEnterpriseSearchTopology -SearchApplication $global:ssa -Active
"#################################################################################################################"
" Search Topology ( ID: " + $global:ssa.ActiveTopology.TopologyId.Guid.ToString() + " ) for: " + "( " + $global:ssa.Name + " )"
"#################################################################################################################"
Get-SPEnterpriseSearchComponent -SearchTopology $activeTopo | Select * | Sort -Property Name
}
#-----------------------------------------------
# Content Sources
#-----------------------------------------------
Function GetContentSources()
{
Write-Host "Collecting Content Source Info"
""
$crawlAccount = (New-Object Microsoft.Office.Server.Search.Administration.Content $global:ssa).DefaultGatheringAccount
"#########################################################################################"
" *** Content Sources (" + $global:ssa.Name + ") *** " + " Crawl Account: " + $crawlAccount
"#########################################################################################"
$contentSources = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $global:ssa;
foreach ($contentSrc in $contentSources) {
""
"------------------------------------------------------------------------------------------------------- "
$contentSrc.Name + " | ( ID:" + $contentSrc.ID + " TYPE:" + $contentSrc.Type + " Behavior:" + $contentSrc.SharePointCrawlBehavior + ")"
"------------------------------------------------------------------------------------------------------- "
foreach ($startUri in $contentSrc.StartAddresses)
{
if ($contentSrc.Type.toString() -ieq "SharePoint")
{
$spSrc = @{}
if ($startUri.Scheme.toString().toLower().startsWith("http"))
{
$isRemoteFarm = $true ## Assume Remote Farm Until Proven Otherwise ##
foreach ($altUrl in Get-SPAlternateUrl) {
if ($startUri.AbsoluteUri.toString() -ieq $altUrl.Uri.toString())
{
$isRemoteFarm = $false
if ($altUrl.UrlZone -ieq "Default")
{
" Start Address: " + $startUri
" AAM Zone: [" + $altUrl.UrlZone + "]"
$inUserPolicy = $false; #assume crawlAccount not inUserPolicy until verified
$webApp = Get-SPWebApplication $startUri.AbsoluteUri;
$IIS = $webApp.IisSettings[[Microsoft.SharePoint.Administration.SPUrlZone]::($altUrl.UrlZone)]
$isClaimsBased = $true
if ($webApp.UseClaimsAuthentication)
{
" Authentication Type: [Claims]"
if (($IIS.ClaimsAuthenticationProviders).count -eq 1)
{
" Authentication Provider: " + ($IIS.ClaimsAuthenticationProviders[0]).DisplayName
}
else
{
" Authentication Providers: "
foreach ($provider in ($IIS.ClaimsAuthenticationProviders))
{
" - " + $provider.DisplayName
}
}
}
else {
$isClaimsBased = $false
" Authentication Type: [Classic]"
if ($IIS.DisableKerberos) { " Authentication Provider: [Windows:NTLM]" }
else { " Authentication Provider:[Windows:Negotiate]" }
}
foreach ($userPolicy in $webApp.Policies)
{
if($isClaimsBased)
{
$claimsPrefix = "i:0#.w|"
}
if ($userPolicy.UserName.toLower().Equals(($claimsPrefix + $crawlAccount).toLower()))
{
$inUserPolicy = $true;
" Web App User Policy: {" + $userPolicy.PolicyRoleBindings.toString() + "}";
}
}
if (!$inUserPolicy)
{
" ---" + $crawlAccount + " is NOT defined in the Web App's User Policy !!!";
}
}
else {
" [" + $altUrl.UrlZone + "] " + $startUri;
" --- Non-Default zone may impact Contextual Scopes (e.g. This Site) and other search functionality"
" ----- Check out https://www.ajcns.com/2021/02/problems-crawling-the-non-defaul-zone-for-a-sharepoint-web-application/ "
}
}
}
if($isRemoteFarm)
{
" This Start Address is NOT local to the Farm"
" Start Address: " + $startUri
}
}
else {
if ($startUri.Scheme.toString().toLower().startsWith("sps")) { " " + $startUri + " [Profile Crawl]" }
else
{
if ($startUri.Scheme.toString().toLower().startsWith("bdc")) { " URL: " + $startUri + " [BDC Content]" }
else { " -" + $startUri; }
}
}
}
else { " Web Address: " + $startUri; }
" ---------------------------------------------"
}
""
}
}
#-----------------------------------------------
# Server Name Mappings
#-----------------------------------------------
function GetServerNameMappings()
{
Write-Host "Getting Server Name Mappings"
""
"#########################################################################################"
" *** Server Name Mappings (" + $global:ssa.Name + ") ***"
"#########################################################################################"
""
$global:ssa | Get-SPEnterpriseSearchCrawlMapping
""
}
#-----------------------------------------------
# Crawl Rules
#-----------------------------------------------
function GetCrawlRules()
{
Write-Host "Getting first 20 Crawl Rules"
""
"#########################################################################################"
" *** Crawl Rules (" + $global:ssa.Name + ") ***"
"#########################################################################################"
""
$Rules = $global:ssa | Get-SPEnterpriseSearchCrawlRule
if ($Rules.count -lt 20) { $Rules }
else
{
""
"Top 20 (of " + $Rules.count + ") Crawl Rules"
"---------------------------------------------"
for ($i = 0; $i -le 21; $i++) { $Rules[$i]; }
}
""
}
#-----------------------------------------------
# Global Search Service
#-----------------------------------------------
function displayGlobalSearchService
{
$searchServiceObjText = @"
- If the 'Search Service' Object\Instance is "Disabled", this will prevent new SSA's from fully creating and can cause other search related issues. To set it back online, do the following: ( remove space between $ and searchServiceObj)
-- $ searchServiceObj = Get-SPEnterpriseSearchService
-- $ searchServiceObj.Status = "Online"
-- $ searchServiceObj.Update()
"@
Write-Host "Getting Search Service Info"
""
"#########################################################################################"
" Search Service "
"#########################################################################################"
$searchServiceObj = Get-SPEnterpriseSearchService
if($searchServiceObj.Status -ne "Online")
{
Write-Warning (" -- You 'Search Service Object' Instances is not Online. It's current status is: " + $searchServiceObj.Status)
"WARNING: -- You 'Search Service Object' Instances is not Online. It's current status is: " + $searchServiceObj.Status
""
$searchServiceObjText
Write-Host ("$searchServiceObjText") -ForegroundColor Gray
Write-Host ""
}
$searchServiceObj
$searchAdminProxy = $searchServiceObj.WebProxy
if($searchAdminProxy.Address -ne $null)
{
" The Search Service has a Web Proxy defined. This will impact ALL SSA's and route crawl traffic to the Proxy regardless if the IE settings are set to NO PROXY"
$searchAdminProxy
}
}
#-----------------------------------------------
# SQSS Info
#-----------------------------------------------
Function GetSQSS()
{
Write-Host "Getting SQSS Information"
""
"#########################################################################################"
" Search Query and Site Settings (SQSS) - These should Only be running on your QPCs"
"#########################################################################################"
""
$instances = Get-SPServiceInstance | where {$_.TypeName -like "Search Query*"} | where {$_.Status -eq "Online"}
if ($instances -ne $null)
{
foreach($instance in $instances)
{
$instance.Server.Address.ToString() + " -- " + $instance.ID.ToString() + " -- " + $instance.Status.ToString()
}
}
}
#-----------------------------------------------
# Service Endpoints
#-----------------------------------------------
function VerifyServiceEndpoints
{
Write-Host "Checking to see if the Search EndPoints are accessible.."
""
"#########################################################################################"
" " + $global:ssa.Name + " - EndPoint Verification "
"#########################################################################################"
""
try
{
foreach($sqssPt in $global:ssa.Endpoints)
{
foreach($sqssEndPoint in $sqssPt.ListenUris)
{
$sqssUri = $sqssEndPoint.AbsoluteUri
$request = $null
$request = [System.Net.WebRequest]::Create($sqssUri)
$request.UseDefaultCredentials = $true
$response = $request.GetResponse()
$sqssUri.ToString() + " -- " + $response.StatusDescription.ToString()
}
}
}
catch
{
Write-Host(" There was a problem reaching $sqssuri : " + $_.Exception.Message) -ForegroundColor Yellow
}
$searchAdminWs = Get-SPServiceApplication | ?{$_.Name -eq $global:ssa.Id}
try
{
foreach($searchAdminpt in $searchAdminWs.Endpoints)
{
foreach($saEndPoint in $searchAdminpt.ListenUris)
{
$searchAdminUri = $saEndPoint.AbsoluteUri
$request = $null
$request = [System.Net.WebRequest]::Create($searchAdminUri)
$request.UseDefaultCredentials = $true
$response = $request.GetResponse()
$searchAdminUri.ToString() + " -- " + $response.StatusDescription.ToString()
}
}
}
catch
{
Write-Host(" There was a problem reaching $searchAdminUri : " + $_.Exception.Message) -ForegroundColor DarkBlue
}
}
#-----------------------------------------------
# Search Service Instances
#-----------------------------------------------
Function GetSSIs
{
Write-Host "Getting Search Service Instances Info"
""
"#########################################################################################"
" Are there any Disabled Search Instances..? "
"#########################################################################################"
""
$at = Get-SPEnterpriseSearchTopology -SearchApplication $global:ssa -Active
$topoCompList = Get-SPEnterpriseSearchComponent -SearchTopology $at
$components = $topoCompList | select ServerName -Unique
$allGood = $true
foreach($searchServer in $components)
{
$ssi = $global:serviceInstances | ?{$_.TypeName -eq "SharePoint Server Search" -and $_.Server.Address -eq $searchServer.ServerName}
$hcsi= $global:serviceInstances | ?{$_.TypeName -match "Search Host Controller Service" -and $_.Server.Address -eq $searchServer.ServerName}
if($ssi.Status -ne "Online")
{
Write-Host ""
Write-Host (" The '" + $ssi.TypeName +"' is not online on server: " + $searchServer.ServerName + ". This instance should be Online. When this object is Disabled, health check jobs will shut down the 'mssearch.exe' service") -ForegroundColor Red
Write-Host (" Enable this instance again by running 'Start-SPEnterpriseSearchServiceInstance " + $searchServer.ServerName + "'") -ForegroundColor Yellow
Write-Host ""
"The '" + $ssi.TypeName +"' is not online on server: " + $searchServer.ServerName + ". This instance should be Online. When this object is Disabled, health check jobs will shut down the 'mssearch.exe' service"
""
" Enable this instance again by running 'Start-SPEnterpriseSearchServiceInstance " + $searchServer.ServerName + "'"
$allGood = $false;
}
elseif($hcsi.Status -ne "Online")
{
Write-Host ""
Write-Host (" The '" + $hcsi.TypeName +"' is not online on server: " + $searchServer.ServerName + ". This instance should be Online. When this object is Disabled, health check jobs will shut down the 'hostcontrollerservice.exe' service") -ForegroundColor Red
Write-Host (" Enable this instance again by running 'Start-SPEnterpriseSearchServiceInstance " + $searchServer.ServerName + "'") -ForegroundColor Yellow
Write-Host ""
"The '" + $hcsi.TypeName +"' is not online on server: " + $searchServer.ServerName + ". This instance should be Online. When this object is Disabled, health check jobs will shut down the 'hostcontrollerservice.exe' service"
""
" Enable this instance again by running 'Start-SPEnterpriseSearchServiceInstance " + $searchServer.ServerName + "'"
$allGood = $false;
}
}
if($allGood)
{
Write-Host ""
Write-Host (" All Search Instances are Online") -ForegroundColor Green
Write-Host ""
""
" All Search Instances are Online"
}
}
#-----------------------------------------------
# Alternate Access Mappings
#-----------------------------------------------
Function GetAAMs
{
Write-Host "Getting Alternate Access Mappings"
""
"###############################################################"
" Alternate Access Mappings"
"###############################################################"
""
" IncomingUrl -- Zone -- PublicUrl "
""
foreach($altUrl in $farm.AlternateUrlCollections)
{
""
"----------------------------------------------"
$altUrl.Name
"----------------------------------------------"
$altUrl | %{$_.incomingUrl + " -- " + $_.Zone + " -- " + $_.PublicUrl}
}
}
##########################################
# SP 2010 Function to get SSA Info
##########################################
function displaySSAInfo ($global:ssa)
{
$crawlAccount = (New-Object Microsoft.Office.Server.Search.Administration.Content $global:ssa).DefaultGatheringAccount;
"###################################################################################### "
" *** " + $global:ssa.Name + " ***" + " | " + " (Crawl Account: " + $crawlAccount + ")"
"###################################################################################### "
$global:ssa.ApplicationName
$global:ssa
"";
"====================================================================================== "
" *** Admin Component (" + $global:ssa.Name + ") ***"
"====================================================================================== "
$global:ssa.AdminComponent; "";
foreach ($ct in $global:ssa.CrawlTopologies) {
"====================================================================================== "
" *** Crawl Topology (" + $global:ssa.Name + ") ***"
"====================================================================================== "
$ct; "";
foreach ($cc in $ct.CrawlComponents){
"---------------------------------------------------------------------------------- "