-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af1677b
commit 58b213c
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
BluebirdPS/public/api_v2/lists/Remove-TwitterListMembership.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function Remove-TwitterListMembership { | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory)] | ||
[ValidateObjectNotNullOrEmpty()] | ||
[BluebirdPS.APIV2.ListInfo.List]$List | ||
) | ||
|
||
$User = Get-TwitterUser | ||
$MemberOfLists = Get-TwitterListMembership | ||
if (Test-TwitterListMembership -List $List -User $User) { | ||
$ListOwner = Get-TwitterUser -User $List.OwnerId | ||
if ($ListOwner.Id -eq $User.Id) { | ||
'You cannot use this command to remove yourself from a list you own. Instead, use Remove-TwitterListMember.' | Write-Warning | ||
return | ||
} | ||
if ($List.OwnerId -in $MemberOfLists.OwnerId) { | ||
foreach ($MemberOf in $MemberOfLists) { | ||
if ($List.Id -ne $MemberOf.Id) { | ||
'You are also a member of {0} owned by {1}' -f $MemberOf.ToShortString(),$ListOwner.ToString() | Write-Warning | ||
} | ||
} | ||
} | ||
$ListOwner | Set-TwitterBlockedUser -Block | Out-Null | ||
$ListOwner | Set-TwitterBlockedUser -Unblock | Out-Null | ||
|
||
if (-Not (Test-TwitterListMembership -List $List -User $User)) { | ||
'Successfully removed from {0}' -f $List.ToShortString() | ||
} | ||
} | ||
|
||
} |