จะเปลี่ยนบัญชีบริการใน SharePoint Server โดยใช้ PowerShell ได้อย่างไร
เปลี่ยนบัญชีบริการใน SharePoint 2016
คุณต้องการเปลี่ยนบัญชีบริการของคุณใน SharePoint หรือไม่? บางทีคุณอาจเพิ่งเปลี่ยนชื่อโดเมนของคุณและจำเป็นต้องอัปเดตการอ้างอิงบัญชีบริการทั้งหมดของคุณ ในคู่มือนี้ เราจะแสดงวิธีเปลี่ยนบัญชีบริการของคุณใน SharePoint อย่างรวดเร็วและง่ายดาย ฉันจะแบ่งปันวิธีใช้ PowerShell เพื่อเปลี่ยนบัญชีบริการของคุณ
หากคุณได้สร้างบัญชีที่มีการจัดการใหม่หรือต้องการเปลี่ยนการแมปบัญชีที่ได้รับการจัดการด้วยบริการ SharePoint 2016 ให้ไปที่:
- การบริหารส่วนกลาง >> ความปลอดภัย
- ใต้ส่วนความปลอดภัยทั่วไป คลิกกำหนดค่าบัญชีบริการ
เลือกบัญชีบริการและบริการที่เหมาะสมจากเมนูแบบเลื่อนลง
- คลิก "ตกลง" เพื่อบันทึกการเปลี่ยนแปลงของคุณ
อ่านเพิ่มเติม: การกำหนดค่าบัญชีที่ได้รับการจัดการใน SharePoint 2016
วิธี PowerShell: จะเปลี่ยนบัญชีบริการใน SharePoint 2013/2016 ได้อย่างไร
ทำไม เนื่องจากไม่ใช่ทุกบัญชีที่สามารถเปลี่ยนแปลงได้ผ่าน SharePoint Central Administration UI นี่คือสคริปต์ของฉันสำหรับเปลี่ยนบัญชีบริการต่างๆ ใน SharePoint โดยใช้ PowerShell โปรดทราบว่ามีบัญชีบริการสี่ประเภทที่เราต้องดูแล:
- อินสแตนซ์ของบริการ SharePoint เช่น แคชการแจกจ่าย การอ้างสิทธิ์ในบริการโทเค็นหน้าต่าง ฯลฯ
- บริการฟาร์ม SharePoint
- บัญชี AppPool ของแอปพลิเคชันบริการ
- บัญชี AppPool ของแอปพลิเคชันบนเว็บ
สคริปต์ PowerShell เพื่อเปลี่ยนบัญชีบริการใน SharePoint (เช่น บริการแคชการแจกจ่าย)
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Custom Function to change Service account of given service
Function Set-ServiceIdentity($svc, $UserName)
{
#Get the current service account
$ProcessIdentity = $svc.Service.ProcessIdentity
if ($ProcessIdentity.Username -ne $UserName)
{
$ProcessIdentity.Username = $UserName
$ProcessIdentity.Update()
Write-Host "Service Account Set!"
}
}
#Get the Service
$Service = Get-SPServiceInstance | Where {$_.TypeName -eq "Claims To Windows Token Service"}
#Call the function to Set "Local System" Identity to given service
Set-ServiceIdentity $Service "NT AUTHORITY\SYSTEM"
สคริปต์ด้านบนเปลี่ยนบัญชีบริการของบริการที่ระบุ
จะเปลี่ยนบัญชีบริการฟาร์มใน SharePoint 2013 ได้อย่างไร
เรายังคงใช้เครื่องมือ STSADM เพื่ออัปเดตบัญชี Farm ของ SharePoint 2013 ใช้บรรทัดคำสั่งนี้เพื่ออัปเดตข้อมูลรับรองบัญชีบริการของ SharePoint Farm:
stsadm -o updatefarmcredentials -userlogin “DOMAIN\username” -password “Password here”
เปลี่ยนบัญชีบริการของกลุ่มแอปพลิเคชันบริการ:
หากต้องการเปลี่ยนบัญชีบริการของกลุ่มแอปพลิเคชัน ให้ใช้สคริปต์ PowerShell นี้:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Custom Function to change Service account of given service
Function Set-ServiceAppPoolIdentity($SvcAppPool, $UserName)
{
if ($SvcAppPool.ProcessAccountName -ne $UserName)
{
Set-SPServiceApplicationPool $SvcAppPool -Account $UserName
Write-Host "Application Pool Service Account Updated!"
}
}
#Get the Service
$SvcAppPool = Get-SPServiceApplicationPool | Where {$_.Name -eq "Service Application App Pool"}
#Call the function to Set "Local System" Identity to given service
Set-ServiceAppPoolIdentity $SvcAppPool "Crescent\SP2016Admin"
เปลี่ยนบัญชีพูลแอปแอปพลิเคชันเว็บ:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Custom Function to change Service account of Web App Pool
Function Set-WebAppPoolIdentity($WebAppPool, $UserName)
{
if ($WebAppPool.ManagedAccount.UserName -ne $UserName)
{
#Get the Managed Account
$ManagedAccount= Get-SPManagedAccount $UserName
#Set the Managed Account
$WebAppPool.ManagedAccount = $ManagedAccount
$WebAppPool.Update()
Write-Host "Web Application App Pool Account Updated!"
}
}
#Get Web App's App Pool
$WebAppPool = (Get-SPWebApplication "https://intranet.crescent.com").ApplicationPool
#Call the function to Set the Managed Account to Web App Pool
Set-WebAppPoolIdentity $WebAppPool "Crescent\SPAdmin"

