Skip to content

Commit

Permalink
Add a switch to override "validating" tenant admin url
Browse files Browse the repository at this point in the history
  • Loading branch information
koskila committed Oct 24, 2023
1 parent 902661b commit 802a519
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions documentation/Rename-PnPTenantSite.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ Accept pipeline input: True
Accept wildcard characters: False
```
### -SuppressAdminUrlValidation
Suppress validating the Tenant Admin URL. Useful if your tenant has a vanity domain or an otherwise non-standard admin site address.
```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False
```
### -Wait
Wait till the renaming of the new site collection is successful. If not specified, a job will be created which you can use to check for its status.
Expand Down
9 changes: 8 additions & 1 deletion src/Commands/Admin/RenameTenantSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class RenameTenantSite : PnPAdminCmdlet
[Parameter(Mandatory = false)]
public SwitchParameter SuppressBcsCheck { get; set; }

[Parameter(Mandatory = false)]
public SwitchParameter SuppressAdminUrlValidation { get; set; };

[Parameter(Mandatory = false)]
public SwitchParameter Wait { get; set; }

Expand Down Expand Up @@ -68,7 +71,11 @@ protected override void ExecuteCmdlet()
OperationId = Guid.Empty
};

var tenantUrl = UrlUtilities.GetTenantAdministrationUrl(AdminContext.Url);
var tenantUrl = AdminContext.Url;
if (!SuppressAdminUrlValidation)
{
tenantUrl = UrlUtilities.GetTenantAdministrationUrl(AdminContext.Url);
}

var results = Utilities.REST.RestHelper.PostAsync<SPOSiteRenameJob>(HttpClient, $"{tenantUrl.TrimEnd('/')}/_api/SiteRenameJobs?api-version=1.4.7", AdminContext, body, false).GetAwaiter().GetResult();
if (!Wait.IsPresent)
Expand Down

0 comments on commit 802a519

Please sign in to comment.