Skip to content

Instantly share code, notes, and snippets.

@joerodgers
Last active March 7, 2024 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joerodgers/de08c8da120796d5fcb49083f056e9bc to your computer and use it in GitHub Desktop.
Save joerodgers/de08c8da120796d5fcb49083f056e9bc to your computer and use it in GitHub Desktop.
Temp workaround for an issue with SPO Mgmt. Shell issue
#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