SharePoint remove site redirect through Graph PowerShell - powershell

is it possible to delete a SharePoint site redirect through the Graph PowerShell SDK? I recently changed the SharePoint site URL of an existing MS365 group and now the old URL (e.g. https://domain.sharepoint.com/sites/GroupA) acts as a redirect to the new SharePoint site URL (e.g. https://domain.sharepoint.com/sites/GroupB). Since I want to reuse the old URL, I need to delete the redirect first.
The Microsoft docs state that this is possible through the SharePoint Online Management Shell. Unfortunately the Shell requires a Windows-based machine, which I cannot use. Therefore, I am trying to do this via the Graph PowerShell SDK.

Unfortunately, Microsoft does not seem to offer any functionality to delete SharePoint sites via the MS Graph API
The Sites API Reference shows that MS Graph is only capable of deleting a permission object on a site rather than a site itself.
As MS Graph API doesn't expose any endpoint to delete sites, it will not be possible with the Graph Powershell module either.
It's unfortunate that the SharePoint Online Management Shell doesn't support Powershell core and that the SharePoint admin center offers no ability to delete these site redirects.
If you're not able to use a Windows machine to achieve this, I suspect a support call to Microsoft may be your only other alternative.

As NiMux mentioned, it's not possible to delete SharePoint sites resp. site redirects via the MS Graph API. But another alternative is the PnP PowerShell module, which among other things provides several SharePoint Online cmdlets. I was able to remove the redirect with the cmdlet Remove-PnPTenantSite.
The module is open-source, community-developed, officially recommended by Microsoft and cross-platform which means it works on an Azure Ubuntu VM (tested it myself).

Related

Authentication in sharepoint Addin

We´ve created a sharepoint-hosted Addin and want to authenticate to our enterprise Azure Active Directory. We tried to migrate the AADTokenProvider from the sharepoint webpart, to get our AccesToken from our AAD.
Following is the dependency which provides the AADTokenProvider
- microsoft/sp-http
Unfortunately the dependencies aren´t standalone packages.
What´s the correct way to accomplish the authentication from sharepoint addin to a Azure AD?
SharePoint Add-in is an identity principal just like a user, and it must be authenticated and authorized to use SharePoint resources. There are three authorization systems that an add-in can use. They are not mutually exclusive.
Three authorization systems and when to use them
Low trust-
A provider-hosted SharePoint Add-in can register with Microsoft Azure Access Control Service (ACS), which issues an access token to the add-in that allows the add-in access to the resources in the SharePoint tenancy or farm on which the add-in is installed. Azure ACS is the trusted token issuer in an OAuth 2.0 Framework "flow" that includes SharePoint and the remote components of the add-in. Add-ins that use this system can be sold in the Office Store. The low-trust system is primarily intended for add-ins whose remote components are hosted in the cloud.
For more information about creating a SharePoint Add-in that uses the low-trust system, see Creating SharePoint Add-ins that use low-trust authorization.
High trust - A provider-hosted add-in can establish trust with SharePoint by using digital certificates. The high-trust system is primarily intended for add-ins whose remote components are hosted on-premises. The add-in can be installed to a SharePoint farm that is not connected to the Internet. The add-in cannot be installed on SharePoint Online or sold in the Office Store.
For more information about creating a SharePoint Add-in that uses the high-trust system, see Creating SharePoint Add-ins that use high-trust authorization.
Cross Domain Library - When the add-in's business logic is in JavaScript, you have the option of using the SharePoint cross-domain library either in place of, or as a supplement to, the low-trust and high-trust systems. The library is also intended for scenarios where the add-in has cloud-hosted components, but the customer's corporate firewall makes it difficult to use the low-trust system. The user's browser blocks scripts from other domains, but the library encapsulates a secure system for working around this restriction. Add-ins that use the library can be sold in the Office Store and can be installed to either SharePoint Online or on-premises SharePoint.
For more information about creating a SharePoint Add-in that uses the cross-domain library, see:
Creating SharePoint Add-ins that use the cross-domain library
Solving cross-domain problems in SharePoint Add-ins (blog post)
Hope it helps.

Azure Web App Management - Application Settings via REST

I am aware that it is possible to manage the Application Settings via CLI Tools or PowerShell.
I am sure I read somewhere that there is a REST API to access them as well, but cannot now find any reference to it.
Is this possible?
I recently was looking into this.
An amazingly awesome site to checkout is https://resources.azure.com/. I believe that the CLI Tools and PowerShell Tools use this REST API. I actually used that site to help me use the PowerShell Tools.
Also there are some simple examples using C# here http://blog.davidebbo.com/2015/12/calling-arm-using-plain-rest.html with the code for that blog here https://github.com/davidebbo/AzureWebsitesSamples/tree/master/HttpClientSample. It will help with authentication.

Running PowerShell scripts programmatically in Azure Web Sites

I want to run PS scripts in C# exactly along the lines of Sample
This works on a Cloud Service (Web Role), on a standard server (with execution policy disabled), but not in a Azure Web Site.
Anyone know why this is so?
I don't know of any official documentation on the issue but there are multiple answers on the related forums where Microsoft employees talk about the limitations of not being able/allowed to launch external processes in Windows Azure Web Sites. See
PHP - Warning: exec(): Unable to fork
PDF Generator failing on Azure Website but not development machine
Recommended HTML to PDF Generator that works on Azure Website Reserved mode with Full Trust
You are probably trying to do that with your powershell script.
You could verify if that is in fact your issue by catching and looking at the exception(s) which should relate to security policies/permissions.

csmanage or powershell commandlets, which one to choose?

After looking around for some information about managing my azure app i found csmanage and powershell commandlets. What are the difference between these applications and which one to choose?
The basis of Windows Azure Services management is REST API and beauty of using REST API is that you can wrap REST in any programming language as longs as there is networking and security infrastructure available. Most of the tools you mentioned above are using REST API underneath and using Windows Azure Service Management API. CSMANAGE and PowerShell Cmdlets are using Windows Azure Service Management API to manager Windows Azure subscriptions. You can learn more about Service Management API here.
There is also another tool call WAPMMC (Windows Azure Platform Management Tool (MMC) which is also built upon Service Management API.
Besides it there are 3rd party tools which are built using Service management API i.e. Cerebrata Powershell cmdlets.
Comparing all of above, I would say Windows Azure Powershell Cmdlets is the most powerful tool among all of these and it has been updated with bug fixes and many more features added frequently. To use it in your machine you just need to download powershell cmdlets and Windows Azure SDK in your machine as these are required.
http://wappowershell.codeplex.com/
Recently I also found a Java based tool called Burp to use REST API directly from its shell to manage Windows Azure subscription. There is no need for .net framework or Azure SDK. You just need a machine with Java runtime and Burp. I have added a blog on this regard here.
I think it depends on what you're more comfortable with. I don't think the CSManage tool is being updated that much any longer (maybe at all - unsure). The PowerShell cmdlets get a lot of attention - both from Microsoft and partners like Cerebrata.
My vote - learn PowerShell and go with the PowerShell cmdlets for working with your Windows Azure apps. Small learning curve and well worth it.

How to programmatically import a CRM Organization?

Is there any way via powershell or some api that I can't seem to find in the CRM 4.0 SDK, that would allow us to automate the refresh from our production CRM 4.0 environment to a Staging CRM server? Obviously the db backup / restore we can script but I cannot find a way to kick off a CRM Import Organization without using the MMC snap-in.
there is a Deployment SDK for Dynamics CRM 4 available. However the interesting part for you is not part of the public api.
The documentation mentions the ImportOrganizationRequest which should be used by the Deployment Manager. Unfortunately, it is marked for internal use. However, there should be no changes to this API as Dynamics CRM 2011 is just around the corner and therefore I would give it a try.
You could use this post in the msdn forums as a starting point.
btw: Dynamics CRM 2011 comes with a set of PowerShell CmdLets which makes the adminstration much more scriptable. Especially Import-CrmOrganization would be the CmdLet which you could use. See my blog post for further information.