Wednesday, April 17, 2013

Could not load the current My Site settings

I have a new SP2013 installation and going into the Setup My Sites, I get the error:
Could not load the current My Site settings

Doing a quick search, I came across this:

It turned out that my Search Service Application was broken as described here:

Unable to retrieve topology component health states. This may be because the admin component is not up and running

I just installed SP2013 RTM on Win2k8R2 SP1 and SQL2012 Enterprise on a separate Win2k8R2 SP1 server. I used Powershell to provision my Search as follows:

$ssi = Get-SPServiceInstance | Where-Object {$_.TypeName -eq 'SharePoint Server Search'}
Start-SPServiceInstance $ssi
WaitForServiceInstance $ssi.TypeName
$searchAdminAppPool = Get-SPServiceApplicationPool -Identity $AppPoolSearchAdmin
$searchQueryAppPool = Get-SPServiceApplicationPool -Identity $AppPoolSearchQuery
New-SPEnterpriseSearchServiceApplication -Name 'Search Service Application' -ApplicationPool $searchQueryAppPool -AdminApplicationPool $searchAdminAppPool
New-SPEnterpriseSearchServiceApplicationProxy -Name 'Search Service Application' -SearchApplication (Get-SPEnterpriseSearchServiceApplication 'Search Service Application')
Set-SPEnterpriseSearchService -ServiceAccount $searchServiceAccount -ServicePassword (ConvertTo-SecureString -AsPlainText -Force $password)

When I go into manage my Search Service Application, I get the following error:
Unable to retrieve topology component health states. This may be because the admin component is not up and running

Figuring that I may have been missing some steps in my Powershell script, I tried unprovisioning my Search Service Application and reprovisioning using Central Administration. Still the same problem. Time to do some searches. Here is what I found.

After doing a lot of reading and considering the various CUs, I went back to my servers to try some of the suggested solutions. Lo and behold, search is working now. The only things I can infer from this is:

  1. Central Administration is doing something to provision Search that is missing from my Powershell script
  2. Some process took its time to execute
  3. Possibly some random factors like memory, etc.

As much as I would like to know the real answer, it is working now, time to move onto next problem.

Friday, April 5, 2013

Managing assemblies with Powershell

A simple way to access assemblies and see what's in them. Still a work in progress. I hope to add more tricks to this post soon.

Load in the assembly
$assembly = [Reflection.Assembly]::LoadFile($assemblyPath)
$assembly = [Reflection.Assembly]::Load($assemblyName)

Get details on a type defined in the assembly
$type = $assembly.DefinedTypes | Where-Object {$_.Name -eq $typeName}
$type.DeclaredConstructors | ForEach-Object {$_.ToString()}
$type.DeclaredMethods | ForEach-Object {$_.ToString()}

To load the assembly for use
Add-Type -Path $assemblyPath #if assembly in file
Add-Type -AssemblyName $assemblyName #if assembly in GAC
For some reason $assemblyName must be the full name contrary to the documentation in Add-Type

Get all assemblies in current AppDomain
[AppDomain]::CurrentDomain.GetAssemblies() | Select-Object FullName | Sort-Object FullName

System.Reflection.Assembly class
Add-Type cmdlet
AppDomain class

Windows Azure storage through Powershell

This is just a first stab at manipulating Windows Azure Storage via Powershell.

Get Microsoft.WindowsAzure.Storage.dll using NuGet 
  1. Navigate to this by first going to the Windows Azure Downloads site.
  2. Select .NET. 
  3. Select Client libraries under Resources.
  4. Instructions on how to download Windows Azure Storage are found here. 
Here is the code I'm using to download files from blob storage

Param (
    [Parameter(Mandatory=$true)] [String] $StorageAccountName,
    [Parameter(Mandatory=$true)] [String] $AccessKey,
    [Parameter(Mandatory=$true)] [String] $BlobFilename,
    [Parameter(Mandatory=$true)] [String] $LocalFilename,
    [String] $StorageAccountEndpoint = "http://$"

Add-Type -Path '.\Microsoft.WindowsAzure.Storage.dll'

$BlobFilename = $BlobFilename.Replace('%20', ' ').Trim('/')
$storageCredentials = New-Object Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($StorageAccountName, $AccessKey)
$blobClient = New-Object Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient($StorageAccountEndpoint, $storageCredentials)
$blob = $blobClient.GetBlobReferenceFromServer($BlobFilename)
$stream = New-Object System.IO.FileStream($LocalFilename, [System.IO.FileMode]::Create)