Monthly Archives: January 2016

Get-SPOAppInfo | SharePoint Online | PowerShell

During SharePoint Online discussion a question popped up “How to get all installed application information in SharePoint Online?” a simple answer is Get-SPOAppInfo cmdlet! But, wait we are partially correct but read this documentation https://technet.microsoft.com/en-us/library/fp161398.aspx. The below image illustrates the parameters of Get-SPOAppInfo both set to be false and it’s not $TRUE – This cmdlet needs either Name or Product ID! So, we can’t use this cmdlet to retrieve all the apps installed in the given Tenant!

Issue:

So we can Get installed apps information by using below

Enough! We are not going to use this. Let’s use Client Side Object Model in PowerShell and solve the issue.

Output

Code:

Import-Module C:\SPPowerKit\Microsoft.SharePoint.Client.dll
Import-Module C:\SPPowerKit\Microsoft.SharePoint.Client.Runtime.dll
#Import-Module C:\SPPowerKit\Microsoft.SharePoint.Client.UserProfiles.dll
Import-Module C:\SPPowerKit\Microsoft.Online.SharePoint.Client.Tenant.dll
function Get-SPOAppInformation
{
    param(
    [Parameter(Mandatory=$true)]
    [string]$SPOUrl,

    [Parameter(Mandatory=$true)]
    [System.Management.Automation.CredentialAttribute()]$SPOCredential
    )

    $ClientContext = [Microsoft.SharePoint.Client.ClientContext]::new($SPOUrl)
    $ClientContext.Credentials = [Microsoft.SharePoint.Client.SharePointOnlineCredentials]::new($SPOCredential.UserName,$SPOCredential.Password)
    $Tenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant -ArgumentList $ClientContext
    $Tenant.Context.Load($Tenant)
    $Tenant.Context.ExecuteQuery()
    $Appinfo = $Tenant.GetAppInfoByName([string]::Empty)
    $Tenant.Context.Load($Appinfo)
    $Tenant.Context.ExecuteQuery()
    $Appinfo
    $ClientContext.Dispose()
}

Get-SPOAppInformation -SPOUrl "https://contoso-admin.sharepoint.com" -SPOCredential "TenantAdmin@contoso.onmicrosoft.com"

Bit more to organize it, we can use PSObject!

Import-Module C:\SPPowerKit\Microsoft.SharePoint.Client.dll
Import-Module C:\SPPowerKit\Microsoft.SharePoint.Client.Runtime.dll
#Import-Module C:\SPPowerKit\Microsoft.SharePoint.Client.UserProfiles.dll
Import-Module C:\SPPowerKit\Microsoft.Online.SharePoint.Client.Tenant.dll
function Get-SPOAppInformation
{
    param(
    [Parameter(Mandatory=$true)]
    [string]$SPOUrl,

    [Parameter(Mandatory=$true)]
    [System.Management.Automation.CredentialAttribute()]$SPOCredential
    )

    $ClientContext = [Microsoft.SharePoint.Client.ClientContext]::new($SPOUrl)
    $ClientContext.Credentials = [Microsoft.SharePoint.Client.SharePointOnlineCredentials]::new($SPOCredential.UserName,$SPOCredential.Password)
    $Tenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant -ArgumentList $ClientContext
    $Tenant.Context.Load($Tenant)
    $Tenant.Context.ExecuteQuery()
    $Appinfocollection = $Tenant.GetAppInfoByName([string]::Empty)
    $Tenant.Context.Load($Appinfocollection)
    $Tenant.Context.ExecuteQuery()
    foreach($Apps in $Appinfocollection)
    {
        $Results = New-Object psobject -Property ([Ordered]@{
        Name = $Apps.Name
        ProductID = $Apps.ProductID
        Source = $Apps.Source
        })
        $Results
    }
    $ClientContext.Dispose()
}

Get-SPOAppInformation -SPOUrl "https://contoso-admin.sharepoint.com" -SPOCredential "TenantAdmin@contoso.onmicrosoft.com"

2016-01-20_10-22-29

SharePoint 2013 Foundation | Central Administration | File Not Found

Yet another day with SharePoint 2013 foundation troubleshooting. I was building a SharePoint 2013 Foundation farm on Windows 2008 R2 Standard with Service Pack 1. The same box has SQL Server 2012! Lesson learnt “Do not do installation on the fly!” J

I was very much sure the box I chose for installing SharePoint 2013 foundation meets the software and hardware requirements. Indeed, scalability and performance was not considered at this point of time.

First and foremost, Symantec Antivirus blocked the configuration wizard at step 4.

Solution: Uninstalled the Symantec Antivirus Software and fixed the access issue.

Then we moved one step ahead and completed the Set up and was bit happy to see the below window

Then, while launching Central Admin we got the glossy and silky error J

Sorry, Something Went Wrong

File Not Found

Followed the below steps

Turned on Custom Error mode – No luck! No clue why including stack trace $true browser didn’t show the error message

Removed Central Admin and Recreated new one – No Luck!

Un-Provisioned the Central Admin and Central Admin Database using below code – No Luck!

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction 0
Function Remove-CentralAdmin
{
    $CA = Get-SPWebApplication -IncludeCentralAdministration | ? {$_.IsAdministrationWebApplication -eq $true}
    if($CA -eq $null)
    {
        "Central Admnistration is missing!"
    }
    foreach($App in $CA)
    {
        $App.UnprovisionGlobally($true)
        foreach($DB in $App.ContentDatabases)
        {
            $DB.Unprovision()
        }
        $App.Delete()
    }
}

Remove-CentralAdmin

Checked the IIS host header and virtual directory settings! All set to good!

Finally, the below simple snippet saved my day!

Get-SPEventLog -StartTime <DateTimeStamp> -EndTime <EndTimeStamp> | ? { $_.Correlation -eq "CorrelationID"
$_.Level -eq 'Unexpected'} | Select Message

Message:

System.IO.FileNotFoundException: Could not load file or assembly ‘MySql.Web.v20, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d’ or one of its dependencies.

The system cannot find the file specified.

Simply Awesome!

Again, I modified the Web.Config File custom errors and stack trace, restarted the IISAdmin service and bounced the server – Just to keep things neat and clean! Bingo, it worked – I got the same error message


The line number 287 in the system machine configuration file is below

<providers>

Line 287: <add name=”MySqlSiteMapProvider” type=”MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web.v20, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d” connectionStringName=”LocalMySqlServer” applicationName=”/” />

</providers>

Solution: Commented this line!

<providers>

<!– <add name=”MySqlSiteMapProvider” type=”MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web.v20, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d” connectionStringName=”LocalMySqlServer” applicationName=”/” /> –>

</providers>

Now, the Central Admin opened up fine J

Keep SharePointing and Enjoy PowerShell !