Last active
March 7, 2024 17:55
-
-
Save joerodgers/de08c8da120796d5fcb49083f056e9bc to your computer and use it in GitHub Desktop.
Temp workaround for an issue with SPO Mgmt. Shell issue
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
#requires -modules "PnP.PowerShell" | |
function ConvertTo-ContainerStatusString | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[int] | |
$ContainerStatus | |
) | |
switch( $ContainerStatus ) | |
{ | |
0 | |
{ | |
return "Active" | |
} | |
1 | |
{ | |
return "Suspended" | |
} | |
2 | |
{ | |
return "Deleted" | |
} | |
} | |
return "Unknown" | |
} | |
Connect-PnPOnline ` | |
-Url "https://$env:O365_TENANT-admin.sharepoint.com" ` | |
-Interactive | |
$list = Get-PnPList -Identity "DO_NOT_DELETE_TENANT_ADMIN_CONTAINER_ENUM_LIST_3b4dc1c7-6dec-4bb2-8245-7dbf7cc4c72d" -Includes Fields | |
$items = Get-PnpListItem -List $list -Fields $list.Fields.InternalName | |
$containers = foreach( $item in $items ) | |
{ | |
if( $item.FieldValues.Owners ) | |
{ | |
$ownersObject = $item.FieldValues.Owners | ConvertFrom-Json | |
$owners = $ownersObject.Owners.UserPrincipalName -join "," | |
} | |
else | |
{ | |
$owners = "NONE" | |
} | |
[PSCustomObject] @{ | |
ContainerDriveId = $item.FieldValues.ContainerDriveId | |
DisplayName = $item.__DisplayName | |
Owners = $owners | |
DeletionDateTime = $item.FieldValues.DeletionDateTime | |
CreationDateTime = $item.FieldValues.CreationDateTime | |
ExpiryDateTime = $item.FieldValues.ExpiryDateTime | |
Status = ConvertTo-ContainerStatusString -ContainerStatus $item.FieldValues.ContainerStatus | |
} | |
} | |
$containers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment