About Me

My photo
a Dynamic and Energetic guy.....

Sunday, August 25, 2013

Update SharePoint 2010 Farm Credentials Using PowerShell


#Input the Managed Account
#If there is only one managed account, the following line could be written as:
#$inputManagedAcct = Get-SPManagedAccount

$inputManagedAcct = Read-Host "Enter managed account as Domain\User" 
#Input the desired new password 
$inputPasswd = Read-Host "Enter new password for managed account" –AsSecureString 
#Change the password for the managed account to the new value 
Set-SPManagedAccount -Identity $inputManagedAcct -NewPassword $inputPasswd



------------------------------------------------------------------------------------------------------------------------------------------------------------       Update after AD Reset    ----------------------------------------------------------------

#Input the Managed Account
#If there is only one managed account, the following line could be written as:
#$inputManagedAcct = Get-SPManagedAccount

$inputManagedAcct = Read-Host "Enter managed account as Domain\User:" 
#Input the Managed Account 
$inputPasswd = Read-Host "Enter password from Active Directory for managed account:" –AsSecureString 
#Change the password in SharePoint for the managed account to the new value 
Set-SPManagedAccount -Identity $inputManagedAcct -ExistingPassword $inputPasswd –UseExistingPassword $true 

Tuesday, August 6, 2013

Get Last 20 Slowest SQL Queries

 SELECT TOP 20
    SUBSTRING(qt.text, (qs.statement_start_offset/2)+1,
    ((CASE qs.statement_end_offset WHEN -1 THEN DATALENGTH(qt.text)
                                   ELSE qs.statement_end_offset
      END - qs.statement_start_offset)/2)+1),
    qs.execution_count,
    qs.total_logical_reads, qs.last_logical_reads,
    qs.min_logical_reads, qs.max_logical_reads,
    qs.total_elapsed_time, qs.last_elapsed_time,
    qs.min_elapsed_time, qs.max_elapsed_time,
    qs.last_execution_time,
    qp.query_plan
FROM
    sys.dm_exec_query_stats qs
CROSS APPLY
    sys.dm_exec_sql_text(qs.sql_handle) qt
CROSS APPLY
    sys.dm_exec_query_plan(qs.plan_handle) qp
WHERE
    qt.encrypted = 0
ORDER BY
    qs.total_logical_reads DESC


My Masters