-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-MgSharepointColumns.ps1
40 lines (36 loc) · 1.11 KB
/
Get-MgSharepointColumns.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function Get-MgSharepointColumns {
[CmdletBinding(DefaultParameterSetName="List columns")]
param (
[Parameter(Mandatory)][string]$SiteId,
[Parameter(Mandatory)][string]$ListId,
[Parameter(Mandatory,ParameterSetName="Get column by id")][string]$ColumnId,
[Parameter(ParameterSetName="List columns")][switch]$ListColumns
)
process {
$Uri = "https://graph.microsoft.com/v1.0/sites/$SiteId/lists/$ListId"
switch ($PsCmdlet.ParameterSetName) {
"Get column by id" {
$Uri = "$Uri/columns/$ColumnId"
}
"List columns" {
$Uri = "$Uri/columns"
}
}
$Splat = @{
"Method" = "GET"
"Uri" = $Uri
"Headers" = @{
"Authorization" = "Bearer $(Get-MgAccessToken)"
}
}
$result = Invoke-RestMethod @Splat
switch ($PsCmdlet.ParameterSetName) {
"Get column by id" {
$Result
}
"List columns" {
$Result.value
}
}
}
}