Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 145 additions & 1 deletion docs/tables/microsoft365_drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,148 @@ from
where
user_id = '[email protected]'
and filter = 'name eq ''Steampipe''';
```
```

### Explore drive quota and storage information
Analyze drive storage usage and quota information to understand how much space users are consuming and monitor storage patterns across your organization.

```sql+postgres
select
name,
drive_type,
quota ->> 'used' as used_bytes,
quota ->> 'total' as total_bytes,
quota ->> 'remaining' as remaining_bytes,
quota ->> 'state' as quota_state,
round((quota ->> 'used')::bigint / 1024.0 / 1024.0, 2) as used_mb,
round((quota ->> 'total')::bigint / 1024.0 / 1024.0 / 1024.0, 2) as total_gb,
round((quota ->> 'remaining')::bigint / 1024.0 / 1024.0 / 1024.0, 2) as remaining_gb
from
microsoft365_drive
where
user_id = '[email protected]'
and quota is not null;
```

```sql+sqlite
select
name,
drive_type,
json_extract(quota, '$.used') as used_bytes,
json_extract(quota, '$.total') as total_bytes,
json_extract(quota, '$.remaining') as remaining_bytes,
json_extract(quota, '$.state') as quota_state,
round(json_extract(quota, '$.used') / 1024.0 / 1024.0, 2) as used_mb,
round(json_extract(quota, '$.total') / 1024.0 / 1024.0 / 1024.0, 2) as total_gb,
round(json_extract(quota, '$.remaining') / 1024.0 / 1024.0 / 1024.0, 2) as remaining_gb
from
microsoft365_drive
where
user_id = '[email protected]'
and quota is not null;
```

### List drives with SharePoint integration
Explore drives that have SharePoint integration by examining the sharepoint_ids field. This is useful for understanding which drives are connected to SharePoint sites and document libraries.

```sql+postgres
select
name,
id,
drive_type,
sharepoint_ids,
owner,
created_date_time,
web_url
from
microsoft365_drive
where
user_id = '[email protected]'
and sharepoint_ids is not null;
```

```sql+sqlite
select
name,
id,
drive_type,
sharepoint_ids,
owner,
created_date_time,
web_url
from
microsoft365_drive
where
user_id = '[email protected]'
and sharepoint_ids is not null;
```

### Get drive details with owner information
Explore detailed drive information including owner details and creation information to understand drive ownership and management within your organization.

```sql+postgres
select
name,
id,
drive_type,
owner,
created_by,
last_modified_by,
created_date_time,
last_modified_date_time,
web_url
from
microsoft365_drive
where
user_id = '[email protected]';
```

```sql+sqlite
select
name,
id,
drive_type,
owner,
created_by,
last_modified_by,
created_date_time,
last_modified_date_time,
web_url
from
microsoft365_drive
where
user_id = '[email protected]';
```

### List drives by type with storage analysis
Analyze drives by type (personal, business, documentLibrary) and their storage usage to understand the distribution of different drive types and their storage patterns.

```sql+postgres
select
drive_type,
count(*) as drive_count,
round(avg((quota ->> 'used')::bigint / 1024.0 / 1024.0), 2) as avg_used_mb,
round(avg((quota ->> 'total')::bigint / 1024.0 / 1024.0 / 1024.0), 2) as avg_total_gb
from
microsoft365_drive
where
user_id = '[email protected]'
and quota is not null
group by
drive_type;
```

```sql+sqlite
select
drive_type,
count(*) as drive_count,
round(avg(json_extract(quota, '$.used') / 1024.0 / 1024.0), 2) as avg_used_mb,
round(avg(json_extract(quota, '$.total') / 1024.0 / 1024.0 / 1024.0), 2) as avg_total_gb
from
microsoft365_drive
where
user_id = '[email protected]'
and quota is not null
group by
drive_type;
```
Loading
Loading