5

I'm uploading my SharePoin Provider Hosted App and installing everything via PowerShell, but the only thing that I cannot find is if it's possible to register a new app using a PowerShell command instead of opening the "/_layouts/15/appregnew.aspx" page.

1

2 Answers 2

3

You can use the Register-SPAppPrincipal command to register an App using PowerShell.

Something like this:

$realm = Get-SPAuthenticationRealm -ServiceContext $web.Site;
$appIdentifier = $clientID  + '@' + $realm;
Register-SPAppPrincipal -DisplayName $appName -NameIdentifier $appIdentifier -Site $web 

Look here for the explanation.

1

You can register the app in office 365 tenancy[SharePoint Online] using the below Azure AD MSOLService PS Script.

$clientID="7c6cbd92-073b-4bc9-9d4a-fc27749f340b";
$newClientSecret = "p/zEuKBqkZRQsz6yRpOafj2f6zZdnQYvONatGWj0N0M=";
$appDomain="Yourdomain.azurewebsites.net";
$appUrl="https://Yourdomain.azurewebsites.net/";
$appName="Your App Name"
$servicePrincipalName = @("$clientID/$appDomain")
$dtStart = [System.DateTime]::Now
$dtEnd = $dtStart.AddYears(10)

Connect-MsolService 
New-MsolServicePrincipal -ServicePrincipalNames $servicePrincipalName -AppPrincipalId $clientID -DisplayName $appName -Type Symmetric -Usage Verify -Value $newClientSecret -Addresses (New-MsolServicePrincipalAddresses -Address $appUrl) -StartDate $dtStart  –EndDate $dtEnd
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Sign -Value $newClientSecret -StartDate $dtStart  –EndDate $dtEnd
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Password -Usage Verify -Value $newClientSecret -StartDate $dtStart  –EndDate $dtEnd

I have written an article on this. Please refer this link.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.