Exchange Onlineコマンドのみで削除

SCSS
# デスクトップへ移動
Set-Location (Join-Path $env:USERPROFILE Desktop)

# ログファイル作成
$LogFile = Get-Date -Format "yyyy-MMdd-HHmmss"
$Process = "TeamsDelete"
$LogPath = Join-Path $env:USERPROFILE "Desktop$Process`_$LogFile.txt"

Start-Transcript -Path $LogPath

# 接続(←ここが重要:シンプルにする)
Connect-ExchangeOnline | Out-Null

# 削除対象Teams(ここに追加)
$Teams = @(
"TMS_o365_jp116232",
"TMS_o365_jp116231"
)

foreach ($Team in $Teams) {

    try {
        Write-Host "Deleting Team: $Team"

        Remove-UnifiedGroup -Identity $Team -Confirm:$false

        Write-Host "SUCCESS: $Team deleted"
    }
    catch {
        Write-Host "ERROR: $Team failed - $_"
    }
}

Stop-Transcript
タイトルとURLをコピーしました