Thursday, February 14, 2013

PowerShell for Service Applications


Noun Windows PowerShell Commands
SPService Install-SPService
SPServiceInstance Get-SPServiceInstance
Start-SPServiceInstance
Stop-SPServiceInstance
SPServiceApplication Get-SPServiceApplication
Publish-SPServiceApplication
Remove-SPServiceApplication
Set-SPServiceApplication
Unpublish-SPServiceApplication
SPServiceApplicationProxy Get-SPServiceApplicationProxy
Remove-SPServiceApplicationProxy
SPIisWebServiceApplicationPool Get-SPServiceApplicationPool
New-SPServiceApplicationPool
Remove-SPServiceApplicationPool
Set-SPServiceApplicationPool

Thursday, February 7, 2013

List of running jobs in SharePoint 2010 through PowerShell


# Get current date
$date = Get-Date

# Show current date
Write-Host "Looking for running jobs with a Last Run Time of greater than or equal to" $date

# Get all Timer jobs and iterate
Get-SPTimerJob | ForEach-Object {

  # Get last run time for job
  $lastRunTime = $_.LastRunTime

  # If run time is greater than/equal to write it out
  if ($lastRunTime -ge $date)
  {
     Write-Host $_.Name", last run at" $_.LastRunTime
  }
}




If you want to include a bit of history, like number of jobs run in the last five minutes, just use this for your $date variable:
$date =  (Get-Date).AddMinutes(-5)