Posts

Showing posts from 2011

Get relative path and name of the active Script in PowerShell

# Get complete file path (eg: D:\RootFolder\ActiveScript.ps1) $0 = $MyInvocation.MyCommand.Definition # Get current Directory file path (eg: D:\FolderA) $dp0 = [System.IO.Path]::GetDirectoryName($0) #To Get the root folder $RootPath = $dp0 | split-path # Get current Drive (eg: D:\) $bits = Get-Item $dp0 | Split-Path -Parent

Check Running Timerjob Status using Powershell

Check the status of timer jobs that have been run by using Windows PowerShell. $Job = Get-SPTimerjob "TimerJob Name" [Array] $JobHistoryList=$Job.HistoryEntries Start-SPTimerJob $Job Write-Host "Running Timer Job" -NoNewline $count = $JobHistoryList.count $countNext = $count+1 while ( $countNext -ne $count) { [Array] $JobHistoryList=$Job.HistoryEntries $count = $JobHistoryList.count Write-Host "." -NoNewline sleep 2 } if ($taxonomyjob[0].status –ne "Succeeded") { Write-Host -f yellow $JobHistoryList[0].status Write-Host -f yellow $JobHistoryList[0].ErrorMessage } else { Write-Host $JobHistoryList[0].status }