So, I've found my perfect PowerShell script to archive Groups in a really nice way. The PS script is interactive and "asks some questions" (Prompt command), so to speak. :) The script looks as follows:
$CheckGroup = Read-Host -Prompt "Enter alias of group to archive"
$AGroup = (Get-UnifiedGroup $CheckGroup -ErrorAction SilentlyContinue)
If ($AGroup) {
Write-Host "Archiving" $AGroup.DisplayName -ForegroundColor Yellow
} Else {
Write-Host $CheckGroup "group not found - terminating"
Return }
# Get lists of current owners and members
$CurrentOwners = (Get-UnifiedGroupLinks -Identity $AGroup.Alias
-LinkType Owners | Select Name)
$CurrentMembers = (Get-UnifiedGroupLinks -Identity $AGroup.Alias
-LinkType Members | Select Name)
# Add a new owner - this is the address of the account that will continue to access the group
$AdminAccount = "Compliance Administrator"
Add-UnifiedGroupLinks -Identity $AGroup.Alias -LinkType Members -Links $AdminAccount
Add-UnifiedGroupLinks -Identity $AGroup.Alias -LinkType Owners -Links $AdminAccount
# Remove the other members and owners
ForEach ($O in $CurrentOwners) {
Remove-UnifiedGroupLinks -Identity $AGroup.Alias -LinkType Owners
-Links $O.Name
-Confirm:$False}
ForEach ($M in $CurrentMembers) {
Remove-UnifiedGroupLinks -Identity $AGroup.Alias -LinkType Members
-Links $M.Name
-Confirm:$False}
# Create SMTP Address for the archived group
$OldSmtpAddress = $AGroup.PrimarySmtpAddress -Split "@"
$NewSmtpAddress = $OldSmtpAddress[0] + "_archived" + "@" + $OldSmtpAddress[1]
$AddressRemove = "smtp:"+$AGroup.PrimarySmtpAddress
# Update Group properties
Set-UnifiedGroup -Identity $AGroup.Alias -AccessType Private
-RequireSenderAuthenticationEnabled $True -HiddenFromAddressListsEnabled $True -CustomAttribute1 "Archived" -CustomAttribute2 (Get-Date -Format s) -PrimarySmtpAddress $NewSmtpAddress
Set-UnifiedGroup -Identity $AGroup.Alias -EmailAddresses @{remove=$AddressRemove}
Write-Host $AGroup.DisplayName "is now archived and" $AdminAccount "is the new group owner
My question:
I wonder, If there's a possibility to make this script "interactive" on an ordinary Sharepoint site? So the assistant can go to this site, execute the PS script and run it completely on the site?