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"
اسکریپت بالا Service account سرویس مشخص شده را تغییر می دهد.
چگونه farm service account را در شیرپوینت تغییر دهیم؟
ما همچنان به ابزار STSADM برای به روز رسانی اکانت farm شیرپوینت متکی هستیم.
از این خط فرمان برای به روز رسانی اعتبار Farm’s service account شیرپوینت استفاده کنید:
stsadm -o updatefarmcredentials -userlogin "DOMAIN\username" -password "Password here"
تغییر Service Application Pool در Service account:
برای تغییر application pool در service accounts ، از این اسکریپت 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"
تغییر App Pool Accounts برنامه های کاربردی وب:
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
#Call the function to Set the Managed Account to Web App Pool
Set-WebAppPoolIdentity$WebAppPool "Crescent\SPAdmin"