รับแอปพลิเคชันเว็บทั้งหมดใน SharePoint โดยใช้ PowerShell
แอปพลิเคชันเว็บเป็นคอนเทนเนอร์ระดับบนสุดใน SharePoint เว็บแอปพลิเคชันแต่ละรายการที่เราสร้างในการดูแลระบบจากศูนย์กลางของ SharePoint จะเชื่อมโยงกับไซต์ใน IIS
จะรับเว็บแอปพลิเคชันทั้งหมดใน SharePoint farm ได้อย่างไร
ในสภาพแวดล้อม SharePoint จำนวนมาก มีเว็บแอปพลิเคชันแยกต่างหากสำหรับฟังก์ชันที่แตกต่างกัน ตัวอย่างเช่น เว็บแอปพลิเคชันหนึ่งอาจใช้สำหรับเว็บไซต์สาธารณะ ในขณะที่อีกแอปพลิเคชันหนึ่งใช้สำหรับอินทราเน็ต อาจมีเว็บแอปพลิเคชันอื่นๆ สำหรับแผนกหรือทีมต่างๆ หากคุณต้องการรับแอปพลิเคชันเว็บเหล่านี้ทั้งหมดจากฟาร์ม SharePoint PowerShell สามารถช่วยได้ โพสต์ในบล็อกนี้จะแสดงวิธีใช้ PowerShell เพื่อรับแอปพลิเคชันเว็บทั้งหมดใน SharePoint
หากต้องการรับรายการแอปพลิเคชันเว็บที่มีอยู่ทั้งหมดใน SharePoint ให้ไปที่:
จะรับแอปพลิเคชันเว็บทั้งหมด SharePoint โดยใช้ PowerShell ได้อย่างไร
cmdlet รับ SPWebApplication ดึงข้อมูลแอปพลิเคชันเว็บทั้งหมดในฟาร์มปัจจุบัน
Get-SPWebApplication
PowerShell cmdlet ด้านบนให้ DisplayName, Url ของแอปพลิเคชันเว็บ SharePoint ทั้งหมด หากต้องการรับเว็บแอปพลิเคชันเฉพาะ ให้ใช้:
Get-SPWebApplication https://yourwebappURL.com
คุณสามารถวนซ้ำผ่านแอปพลิเคชันเว็บใน PowerShell ได้ดังนี้:
#Get all web applications sharepoint using powershell
$WebAppColl = Get-SPWebApplication
#Iterate through each web application
Foreach ($WebApp in $WebAppColl)
{
$Webapp.Url
}
#Or a one liner to loop through web applications
#Get-SPWebApplication | Select URL
สิ่งนี้จะทำงานได้ทั้งบนสภาพแวดล้อม SharePoint 2013 และ 2016 สคริปต์ต้องการให้คุณมีสิทธิ์ของผู้ดูแลฟาร์มจึงจะรันได้
รับรายละเอียดแอปพลิเคชันเว็บทั้งหมดใน SharePoint โดยใช้ PowerShell
มาตรวจสอบแอปพลิเคชันเว็บทั้งหมดใน SharePoint พร้อมรายละเอียดเพิ่มเติม เช่น จำนวนฐานข้อมูลเนื้อหา ประเภทการรับรองความถูกต้อง ชื่อกลุ่มแอปพลิเคชัน ฯลฯ และสร้างรายงาน:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Parameters
$ReportOutput= "C:\WebApplications-Report.csv"
$DataCollection = @()
#Get all web applications sharepoint using powershell
$WebAppColl = Get-SPWebApplication
Foreach ($WebApp in $WebAppColl)
{
#Determine the Authentication Type of the web application
if ($WebApp.UseClaimsAuthentication) { $AuthticationTYpe = "Claims"} else {$AuthticationTYpe = "Classic" }
#Get All Managed Paths of the web application
$ManagedPaths =(Get-SPManagedPath -WebApplication $WebApp | Select -ExpandProperty Name) -join ","
$WebAppData = new-object PSObject
$WebAppData | add-member -membertype NoteProperty -name "Web Application Name" -Value $WebApp.Name
$WebAppData | add-member -membertype NoteProperty -name "URL" -Value $WebApp.URL
$WebAppData | add-member -membertype NoteProperty -name "No.of Content Databases" -Value $WebApp.ContentDatabases.Count
$WebAppData | add-member -membertype NoteProperty -name "Authentication Type" -Value $AuthticationTYpe
$WebAppData | add-member -membertype NoteProperty -name "Application Pool" -Value $WebApp.ApplicationPool.DisplayName
$WebAppData | add-member -membertype NoteProperty -name "Outgoing E-mail" -Value $WebApp.OutboundMailServiceInstance[0].Server.Address
$WebAppData | add-member -membertype NoteProperty -name "Managed Paths" -Value $ManagedPaths
$DataCollection += $WebAppData
}
#Export Results to a CSV File
$DataCollection | Export-csv $ReportOutput -notypeinformation
Write-Host "Web Application Audit Report has been Generated!" -f Green
สคริปต์นี้สร้างรายงาน CSV:


