Skip to content

Instantly share code, notes, and snippets.

@claw0ry
claw0ry / SlowView.ps1
Created September 1, 2016 11:37
Slow down Powershell output
Function SlowView {
process { $_; Start-Sleep -Milliseconds 500 }
}
@claw0ry
claw0ry / CLI.class.php
Created December 2, 2013 13:17
Simple IO class for php CLI.
/*
* Description: Simple IO class for php CLI
* Author: Mads Aune
*/
if(!defined("STDIN")) { define('STDIN', fopen('php://stdin', 'r')); }
class CLI {
public static function getLine($prompt = '') {
echo $prompt . "> ";
@claw0ry
claw0ry / MicrosoftGraphAuth.ps1
Last active December 18, 2019 12:29
Basic Microsoft Graph Authentication in Powershell
[CmdletBinding()]
param (
[Parameter(Mandatory=$True)]
[string]
$TenantName,
[Parameter(Mandatory=$True)]
[string]
$AppId,
@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 = "."
)
@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
function Get-MIDServerDownloadUrl {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string[]]
$InstanceName,
[Parameter()]
[ValidateSet("windows", "linux")]
[string]
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…
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> 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…
# replace object_id with the 'Object ID' of your app registration
Get-AzADAppPermission -ObjectId <object_id>