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.


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.

| improve this answer | |

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

$newClientSecret = "p/zEuKBqkZRQsz6yRpOafj2f6zZdnQYvONatGWj0N0M=";
$appName="Your App Name"
$servicePrincipalName = @("$clientID/$appDomain")
$dtStart = [System.DateTime]::Now
$dtEnd = $dtStart.AddYears(10)

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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