Wednesday, July 22, 2015

Wait for timerjob to finish

I had an old PowerShell latying around. The PowerShell script wait for a given timerjob to be finished.
1 $sleeptime = 5
2 $timerjobname = "MetadataHubTimerJob"
3
4 $timerjob = Get-SPTimerJob | Where {$_.Name -eq $timerjobname}
5 if($timerjob)
6 {
7 $countBefore = $timerjob.HistoryEntries | select "EndTime"
8
9 $timerjob.RunNow()
10 "Waiting for timerjob: $($timerjob.Name) to finish"
11 while($true)
12 {
13 Start-Sleep -Seconds $sleeptime
14 $countAfter = $timerjob.HistoryEntries | select "EndTime"
15
16 if($countAfter.Count -gt $countBefore.Count)
17 {
18 "The timejob $($timerjob.Name) is done"
19 break
20 }
21 else
22 {
23 "Still waiting on timerjob: $($timerjob.Name) to finish..."
24 }
25 }
26 }
27 else
28 {
29 "The timerjob: $($timerjob.Name) was not found."
30 }

Wednesday, July 8, 2015

PowerShell script to restart application pools, with remote Powershell

Has a follow up on my blog post about a PowerShell script to restart application pools. This script do it with remote PowerShell

$computername = "myserver"
$script = {   
    Import-Module WebAdministration
    (Get-Item "IIS:\Sites\*"| Select-Object applicationPool).applicationPool | % { Restart-WebAppPool $_ }
}
$cred = Get-Credential
$remotesession = New-PSSession -ComputerName $computername -Credential $cred
Invoke-Command -Session $remotesession -ScriptBlock $script

PowerShell script to restart application pools

Two line PowerShell script to restart all application pools on a server

1 #Import WebAdministration
2 Import-Module WebAdministration
3 #Find, pipe and restart
4 (Get-Item "IIS:\Sites\*" | Select-Object applicationPool).applicationPool | % { Restart-WebAppPool $_ }
5

Tuesday, June 30, 2015

Unable to type in visual studio

After not using an Azure VM in a few weeks, I booted machine and started Visual Studio to get some work done. But I could not type in any documents. It was like all the document was in some kind of read only mode :S After rebooting (several times) I found this stackoverflow post. http://stackoverflow.com/questions/24825925/unable-to-type-in-visual-studio

In short my resharpers project cache was broken and I need to delete it.

Saturday, June 20, 2015

SharePoint Crawler Troubleshooting using fiddler

A nice blog by Matthew McDermott (https://twitter.com/MatthewMcD/) to using fiddler as a proxy to see how SharePoints search crawlers is build its web request and what the web site reposonse back with.

Link to blog post: http://www.ableblue.com/blog/archive/2012/01/04/troubleshooting-sharepoint-search-crawl/