Forum Discussion
null null
Aug 02, 2017Iron Contributor
recycling the deleted site from recycle bin
I have put together a script to delete a site collection from te recycle bin of office 365 Admin SharePoint It executes fine however it starts with an exception with ".ctor". $siteAdminURL = "ht...
- Aug 02, 2017
Is what you've listed the full script? If so I think the error results from the way you use $Credentials. There's no $cred variable in the script. Besides, as far as I know Connect-SPOService doesn't accept an object of type SharePointOnlineCredentials to be passed as an argument.
The modified script below works for me without any error
$cred = Get-Credential $siteAdminURL = "https://<mydomain>-admin.sharepoint.com" Import-Module Microsoft.Online.SharePoint.PowerShell –DisableNameChecking Connect-SPOService -Url $siteAdminUrl -Credential $cred $siteurl = read-host "enter the site collection URL" Remove-SPODeletedSite –Identity $siteurl –Confirm:$false
paulpascha
Aug 02, 2017Bronze Contributor
Is what you've listed the full script? If so I think the error results from the way you use $Credentials. There's no $cred variable in the script. Besides, as far as I know Connect-SPOService doesn't accept an object of type SharePointOnlineCredentials to be passed as an argument.
The modified script below works for me without any error
$cred = Get-Credential $siteAdminURL = "https://<mydomain>-admin.sharepoint.com" Import-Module Microsoft.Online.SharePoint.PowerShell –DisableNameChecking Connect-SPOService -Url $siteAdminUrl -Credential $cred $siteurl = read-host "enter the site collection URL" Remove-SPODeletedSite –Identity $siteurl –Confirm:$false