Skip to content

Instantly share code, notes, and snippets.

PS> Invoke-MgRestMethod -Method Get -Uri "https://graph.microsoft.com/beta/users"
Name Value
---- -----
@odata.context https://graph.microsoft.com/beta/$metadata#users
value {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, xxxxxxxx-xxxx-xxxx-xx…
@odata.nextLink https://graph.microsoft.com/beta/users?$skiptoken=RFNwdAIAAQAAAB19Y3FybC8hcm6lLmZsYWRtYXJrQGdtYWls…
PS> Get-Command -Module Microsoft.Graph* "get*userprofile*"
CommandType Name Version Source
----------- ---- ------- ------
Function Get-MgUserProfile 1.25.0 Microsoft.Graph.People
Function Get-MgUserProfileAccount 1.25.0 Microsoft.Graph.People
Function Get-MgUserProfileAddress 1.25.0 Microsoft.Graph.People
Function Get-MgUserProfileAnniversary 1.25.0 Microsoft.Graph.People
Function Get-MgUserProfileAward 1.25.0 Microsoft.Graph.People
...
PS> Find-MgGraphCommand -Uri "https://graph.microsoft.com/beta/users"
APIVersion: beta
Command Module Method URI OutputType Permissions
------- ------ ------ --- ---------- -----------
Get-MgUser Users GET /users IMicrosoftGraphUser1 {DeviceManagementApps.Read.All, DeviceManagementApps.…
New-MgUser Users POST /users IMicrosoftGraphUser1 {DeviceManagementApps.ReadWrite.All, DeviceManagement…
# GET https://graph.microsoft.com/beta/users
Get-MgUser
# GET https://graph.microsoft.com/beta/users/<id>/authentication/methods
Get-MgUserAuthenticationMethod
# GET https://graph.microsoft.com/beta/roleManagement/directory/roleDefinitions/<id>
Get-MgRoleManagementDirectoryRoleDefinition
PS> [Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser].GetProperties()
...
MemberType : Property
Name : UserType
DeclaringType : Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser
ReflectedType : Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser
MetadataToken : 385892877
Module : Microsoft.Graph.Users.private.dll
IsCollectible : False
PropertyType : System.String
# we need to get the full help document to see the OUTPUT section
PS> Get-Help Get-MgUser -Full
...
INPUTS
Microsoft.Graph.PowerShell.Models.IUsersIdentity
OUTPUTS
Microsoft.Graph.PowerShell.Models.IMicrosoftGraphUser
...
PS> Select-MgProfile -Name beta
PS> Get-MgPolicyAuthorizationPolicy | gm | Where-Object { $_.Name -eq "PermissionGrantPolicyIdsAssignedToDefaultUserRole" }
TypeName: Microsoft.Graph.PowerShell.Models.MicrosoftGraphAuthorizationPolicy1
Name MemberType Definition
---- ---------- ----------
PermissionGrantPolicyIdsAssignedToDefaultUserRole Property string[] PermissionGrantPol…
function Get-MIDServerDownloadUrl {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string[]]
$InstanceName,
[Parameter()]
[ValidateSet("windows", "linux")]
[string]
@claw0ry
claw0ry / Find-TerraformAzureResources.ps1
Last active June 3, 2021 09:11
List azurerm/azuread resources in Terraform project
(Get-ChildItem -File -Recurse | Get-Content | Select-String -Pattern 'resource "(azurerm_.+|azuread_.+)" ".*"' -AllMatches).Matches |
ForEach-Object { $_.Groups[1].Value } |
Sort-Object -Unique
@claw0ry
claw0ry / Get-LinesOfCode.ps1
Last active May 20, 2021 13:34
Get-LinesOfCode
# Get lines of code in a powershell project
# Inspiration: https://www.limilabs.com/blog/source-lines-of-code-count-using-powershell
function Get-LinesOfCode {
[CmdletBinding()]
param (
[Parameter()]
[string]
$Path = "."
)