0

I need help finding a powershell script that would register my "Office365 SharePoint application" with Azure, i want to extract the Client ID from that script.

What I've tried (sorry for not mentioning the sources, i got these online):

try {
    # Load the SharePoint snap in
    $ver = $host | select version
    if ($ver.Version.Major -gt 1) {
        $host.Runspace.ThreadOptions = "ReuseThread"
    } 
    if ((Get-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null) {
        Add-PSSnapin Microsoft.SharePoint.PowerShell
    }
    [void][System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
} catch {
    throw "A problem occured while loading DLLs: $_.Exception.Message"
}

The above code threw an error saying Microsoft.SharePoint.PowerShell does not exist on my machine.

And later I wanted to try this code, but obviously i did not because of the above error

function Register-App($siteCollection, $appFile, $appTitle) {
try {
    $clientID = [guid]::NewGuid().ToString()
    $web = Get-SPWeb -Identity $siteCollection

    $realm = Get-SPAuthenticationRealm -ServiceContext $web.Site
    $appIdentifier = $clientID  + '@' + $realm

    #Register the App with given ClientId
    Register-SPAppPrincipal -DisplayName $appTitle -NameIdentifier $appIdentifier -Site $web | Out-Null

    $app = Import-SPAppPackage -Path $appFile -Site $siteCollection -Source ObjectModel -Confirm:$false     

    #Install the App
    Install-SPApp -Web $siteCollection -Identity $app   | Out-Null
} catch {
    throw "A problem occured while trying to register the app... $_.Exception.Message"
 }
}

Any help would be appreciated; For dislikers, help improve this question.

Thanks

1
  • 1
    did you check if the error message is correct and your machine happens to miss Microsoft.SharePoint.PowerShell? Commented May 26, 2016 at 15:05

1 Answer 1

0

"Microsoft.SharePoint.PowerShell" available after you install the SharePoint 2013. After you install SharePoint 2013, applicable Windows PowerShell cmdlets are available in the SharePoint 2013 Management Shell.

More detail about SharePoint 2013 Management Shell, please refer to here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.