Skip to content

Commit

Permalink
Replace with BOM-less files
Browse files Browse the repository at this point in the history
  • Loading branch information
michevnew authored Jul 22, 2023
1 parent 5a81be9 commit 96b62b2
Show file tree
Hide file tree
Showing 54 changed files with 379 additions and 407 deletions.
2 changes: 1 addition & 1 deletion AADRolesInventory-Graph.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
[CmdletBinding(SupportsShouldProcess)] #Make sure we can use -WhatIf and -Verbose
Param([switch]$IncludePIMEligibleAssignments) #Indicate whether to include PIM elibigle role assignments in the output. NOTE: Currently the RoleManagement.Read.Directory application permissions seems to be required!

Expand Down
2 changes: 1 addition & 1 deletion AADRolesInventory-MG.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
[CmdletBinding(SupportsShouldProcess)] #Make sure we can use -WhatIf and -Verbose
Param([switch]$IncludePIMEligibleAssignments) #Indicate whether to include PIM elibigle role assignments in the output. NOTE: Currently the RoleManagement.Read.Directory scope seems to be required!

Expand Down
4 changes: 2 additions & 2 deletions AADRolesInventory.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Do a check for the AzureAD module
#Do a check for the AzureAD module
if (!(Get-Module AzureAD -ListAvailable)) { Write-Host -BackgroundColor Red "This script requires a recent version of the AzureAD PowerShell module. Download it here: https://www.powershellgallery.com/packages/AzureAD/"; return }

#Do a connectivity check
Expand Down Expand Up @@ -31,4 +31,4 @@ foreach ($AADRole in $AADRoles) {

#format and export
$report = foreach ($key in ($RolesHash.Keys)) { $RolesHash[$key] | % { [PSCustomObject]$_ } }
$report | sort DisplayName #| Export-CSV -nti -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_AzureADRoleInventory.csv"
$report | sort DisplayName | Export-CSV -nti -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_AzureADRoleInventory.csv"
2 changes: 1 addition & 1 deletion AAD_Groups_MemberOf_inventory.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Make sure to fill in all the required variables before running the script
#Also make sure the AppID used corresponds to an app with sufficient permissions, as follows:
# Directory.Read.All
Expand Down
2 changes: 1 addition & 1 deletion AAD_Groups_MemberOf_inventoryMG.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Make sure to fill in all the required variables before running the script
#Also make sure the AppID used corresponds to an app with sufficient permissions, as follows:
# Directory.Read.All
Expand Down
2 changes: 1 addition & 1 deletion AAD_Groups_Members_inventory.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Make sure to fill in all the required variables before running the script
#Also make sure the AppID used corresponds to an app with sufficient permissions, as follows:
# Directory.Read.All
Expand Down
2 changes: 1 addition & 1 deletion AAD_Groups_Members_inventoryMG.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Requires -Modules @{ ModuleName="Microsoft.Graph.Groups"; ModuleVersion="1.19.0" }
#Requires -Modules @{ ModuleName="Microsoft.Graph.Users"; ModuleVersion="1.19.0" }

Expand Down
2 changes: 1 addition & 1 deletion AU_memberOf_inventory.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Make sure to fill in all the required variables before running the script
#Also make sure the AppID used corresponds to an app with sufficient permissions, as follows:
# Directory.Read.All
Expand Down
4 changes: 2 additions & 2 deletions Calendar_Permissions_inventory.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeRoomMailboxes,[switch]$CondensedOutput)
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeRoomMailboxes,[switch]$CondensedOutput)

function Get-CalendarPermissionInventory {
<#
Expand Down Expand Up @@ -145,4 +145,4 @@ function Get-CalendarPermissionInventory {
}

#Invoke the Get-CalendarPermissionInventory function and pass the command line parameters. Make sure the output is stored in a variable for reuse, even if not specified in the input!
Get-CalendarPermissionInventory @PSBoundParameters -OutVariable global:varPermissions | Export-Csv -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_CalendarPermissions.csv" -NoTypeInformation -Encoding UTF8 -UseCulture
Get-CalendarPermissionInventory @PSBoundParameters -OutVariable global:varPermissions #| Export-Csv -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_CalendarPermissions.csv" -NoTypeInformation -Encoding UTF8 -UseCulture
2 changes: 1 addition & 1 deletion Calendar_Permissions_inventoryV2.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeRoomMailboxes)
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeRoomMailboxes)

#For details on what the script does and how to run it, check: https://www.michev.info/blog/post/4007/updated-version-of-the-calendar-permissions-inventory-script

Expand Down
4 changes: 2 additions & 2 deletions DG_MemberOf_inventory.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeMailUsers,[switch]$IncludeMailContacts,[switch]$IncludeGuestUsers)
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeMailUsers,[switch]$IncludeMailContacts,[switch]$IncludeGuestUsers)

function Check-Connectivity {
#Make sure we are connected to Exchange Remote PowerShell
Expand Down Expand Up @@ -121,4 +121,4 @@ function Get-DGMembershipInventory {
}

#Invoke the Get-DGMembershipInventory function and pass the command line parameters. Make sure the output is stored in a variable for reuse, even if not specified in the input!
Get-DGMembershipInventory @PSBoundParameters -OutVariable global:varDGMemberOf #| Export-Csv -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_DGMemberOfReport.csv" -NoTypeInformation
Get-DGMembershipInventory @PSBoundParameters -OutVariable global:varDGMemberOf #| Export-Csv -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_DGMemberOfReport.csv" -NoTypeInformation
2 changes: 1 addition & 1 deletion DG_MemberOf_inventoryV2.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeRoomMailboxes,[switch]$IncludeMailUsers,[switch]$IncludeMailContacts,[switch]$IncludeGuestUsers,[switch]$IncludeUsers)
param([switch]$IncludeAll,[switch]$IncludeUserMailboxes,[switch]$IncludeSharedMailboxes,[switch]$IncludeRoomMailboxes,[switch]$IncludeMailUsers,[switch]$IncludeMailContacts,[switch]$IncludeGuestUsers,[switch]$IncludeUsers)

function Check-Connectivity {
#Make sure we are connected to Exchange Online PowerShell
Expand Down
2 changes: 1 addition & 1 deletion DG_members_recursive.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
[CmdletBinding()] #Make sure we can use -Verbose
Param([switch]$IncludeAll,[switch]$IncludeDGs,[switch]$IncludeDynamicDGs,[switch]$IncludeO365Groups,[switch]$RecursiveOutput,[switch]$RecursiveOutputListGroups)

Expand Down
2 changes: 1 addition & 1 deletion DG_members_recursiveV2.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Requires -Modules @{ ModuleName="ExchangeOnlineManagement"; ModuleVersion="3.0.0" }
[CmdletBinding()] #Make sure we can use -Verbose
Param([switch]$IncludeAll,[switch]$IncludeDGs,[switch]$IncludeDynamicDGs,[switch]$IncludeO365Groups,[switch]$RecursiveOutput,[switch]$RecursiveOutputListGroups,[string[]]$GroupList)
Expand Down
2 changes: 1 addition & 1 deletion GraphSDK_Bulk_change_service.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Requires -Modules @{ ModuleName="Microsoft.Graph.Users"; ModuleVersion="1.19.0" }
#Requires -Modules @{ ModuleName="Microsoft.Graph.Identity.DirectoryManagement"; ModuleVersion="1.19.0" }

Expand Down
2 changes: 1 addition & 1 deletion Graph_Bulk_change_service.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#For details on what the script does and how to run it, check: https://www.michev.info/blog/post/3555/bulk-enable-specific-services-via-the-graph-api
#For details on what the script does and how to run it, check: https://www.michev.info/blog/post/3555/bulk-enable-specific-services-via-the-graph-api

#Set the authentication details
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Expand Down
2 changes: 1 addition & 1 deletion Graph_CA_report.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Set up
#Set up
$AppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" #clientID of your AAD app, must have Policy.Read.All permissions. Also needs Directory.Read.All permissions if you want the "readable" object names
$client_secret = Get-Content .\ReportingAPIsecret.txt | ConvertTo-SecureString
$app_cred = New-Object System.Management.Automation.PsCredential($AppId, $client_secret)
Expand Down
2 changes: 1 addition & 1 deletion Graph_Devices_MemberOf.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Set the authentication details
#Set the authentication details
$tenantID = "tenant.onmicrosoft.com" #your tenantID or tenant root domain
$appID = "12345678-1234-1234-1234-1234567890AB" #the GUID of your app. For best result, use app with Directory.Read.All scope granted
$client_secret = "XXXXXXXXXXXXXXXXXXX" #client secret for the app
Expand Down
2 changes: 1 addition & 1 deletion Graph_Flow_report.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Load the MSAL binaries
#Load the MSAL binaries
Add-Type -LiteralPath "C:\Program Files\PackageManagement\NuGet\Packages\Microsoft.IdentityModel.Abstractions.6.22.0\lib\net45\Microsoft.IdentityModel.Abstractions.dll"
Add-Type -LiteralPath "C:\Program Files\PackageManagement\NuGet\Packages\Microsoft.Identity.Client.4.54.1\lib\net45\Microsoft.Identity.Client.dll"

Expand Down
65 changes: 34 additions & 31 deletions Graph_Last_Login_Date.ps1
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
#Set up
$AppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" #clientID of your AAD app, must have User.Read.All, Directory.Read.All, Auditlogs.Read.All permissions
$client_secret = Get-Content .\ReportingAPIsecret.txt | ConvertTo-SecureString
$app_cred = New-Object System.Management.Automation.PsCredential($AppId, $client_secret)
$TenantId = "tenant.onmicrosoft.com" #your tenant

$body = @{
client_id = $AppId
scope = "https://graph.microsoft.com/.default"
client_secret = $app_cred.GetNetworkCredential().Password
grant_type = "client_credentials"
}

#simple code to get an access token, add your own handlers as needed
try { $tokenRequest = Invoke-WebRequest -Method Post -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" -ContentType "application/x-www-form-urlencoded" -Body $body -UseBasicParsing -ErrorAction Stop }
catch { Write-Host "Unable to obtain access token, aborting..."; return }

$token = ($tokenRequest.Content | ConvertFrom-Json).access_token

#prepare auth header
$authHeader1 = @{
'Content-Type'='application\json'
'Authorization'="Bearer $token"
}

#exectue the actual query
$LastLogin = Invoke-WebRequest -Headers $AuthHeader1 -Uri "https://graph.microsoft.com/beta/users?`$select=displayName,userPrincipalName,signInActivity"
$result = ($LastLogin.Content | ConvertFrom-Json).Value
$result | select DisplayName,UserPrincipalName,@{n="LastLoginDate";e={$_.signInActivity.lastSignInDateTime}}

#$result | Export-Csv -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_LastLoginDate.csv" -NoTypeInformation -Encoding UTF8 -UseCulture
#Set up
$AppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" #clientID of your AAD app, must have User.Read.All, Directory.Read.All, Auditlogs.Read.All permissions
$client_secret = Get-Content '.\Login script\ReportingApiSecret.txt' | ConvertTo-SecureString
$app_cred = New-Object System.Management.Automation.PsCredential($AppId, $client_secret)
$TenantId = "michev.onmicrosoft.com" #your tenant

$body = @{
client_id = $AppId
scope = "https://graph.microsoft.com/.default"
client_secret = $app_cred.GetNetworkCredential().Password
grant_type = "client_credentials"
}

#simple code to get an access token, add your own handlers as needed
try { $tokenRequest = Invoke-WebRequest -Method Post -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" -ContentType "application/x-www-form-urlencoded" -Body $body -UseBasicParsing -ErrorAction Stop }
catch { Write-Host "Unable to obtain access token, aborting..."; return }

$token = ($tokenRequest.Content | ConvertFrom-Json).access_token

#prepare auth header
$authHeader1 = @{
'Content-Type'='application\json'
'Authorization'="Bearer $token"
}

#exectue the actual query
$LastLogin = Invoke-WebRequest -Headers $AuthHeader1 -Uri "https://graph.microsoft.com/beta/users?`$select=displayName,userPrincipalName,signInActivity"
$result = ($LastLogin.Content | ConvertFrom-Json).Value
$result | select DisplayName,UserPrincipalName,@{n="LastLoginDate";e={$_.signInActivity.lastSignInDateTime}}

#$result | Export-Csv -Path "$((Get-Date).ToString('yyyy-MM-dd_HH-mm-ss'))_LastLoginDate.csv" -NoTypeInformation -Encoding UTF8 -UseCulture


#https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-beta&tabs=http#example-5-list-the-last-sign-in-time-of-users-in-a-specific-time-range
2 changes: 1 addition & 1 deletion Graph_ODFB_remove_all_shared.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
# Make sure to fill in all the required variables before running the script
# Also make sure the AppID used corresponds to an app with sufficient permissions, as follows:
# User.Read.All to enumerate all users in the tenant
Expand Down
6 changes: 3 additions & 3 deletions Graph_ODFB_shared_files.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
# Make sure to fill in all the required variables before running the script
# Also make sure the AppID used corresponds to an app with sufficient permissions, as follows:
# User.Read.All to enumerate all users in the tenant
Expand Down Expand Up @@ -199,7 +199,7 @@ function Renew-Token {
}

try {
Set-Variable -Name authenticationResult -Scope Global -Value (Invoke-WebRequest -Method Post -Uri $url -Debug -Verbose -Body $body)
Set-Variable -Name authenticationResult -Scope Global -Value (Invoke-WebRequest -Method Post -Uri $url -Debug -Verbose -Body $body -ErrorAction Stop)
$token = ($authenticationResult.Content | ConvertFrom-Json).access_token
}
catch { $_; return }
Expand Down Expand Up @@ -271,7 +271,7 @@ if ($ExpandFolders -and ($depth -le 0)) { $depth = 0 }

#Get a list of all users, make sure to handle multiple pages
$GraphUsers = @()
$uri = "https://graph.microsoft.com/v1.0/users/?$`select=displayName,mail,userPrincipalName,id,userType&`$top=999&`$filter=userType eq 'Member'"
$uri = "https://graph.microsoft.com/v1.0/users/?`$select=displayName,mail,userPrincipalName,id,userType&`$top=999&`$filter=userType eq 'Member'"
do {
$result = Invoke-GraphApiRequest -Uri $uri -Verbose:$VerbosePreference -ErrorAction Stop
$uri = $result.'@odata.nextLink'
Expand Down
4 changes: 2 additions & 2 deletions Graph_Remove_all_licenses.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Set the authentication details
#Set the authentication details
$tenantID = "tenant.onmicrosoft.com" #your tenantID or tenant root domain
$appID = "12345678-1234-1234-1234-1234567890AB" #the GUID of your app. For best result, use app with User.ReadWrite.All scope granted
$client_secret = "XXXXXXXXXXXXXXXXXXX" #client secret for the app
Expand Down Expand Up @@ -63,4 +63,4 @@ foreach ($user in $users) {
}}
#Simple anti-throttling control
Start-Sleep -Milliseconds 200
}
}
2 changes: 1 addition & 1 deletion Graph_Teams_channel_SMTP.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
# Make sure to fill in all the required variables before running the script
# Also make sure the AppID used corresponds to an app with sufficient permissions, as follows:
# Group.Read.All or Directory.Read.All to read all Groups
Expand Down
2 changes: 1 addition & 1 deletion Groups_Owner_Inventory.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param([switch]$IncludeExchangeManagedBy)
param([switch]$IncludeExchangeManagedBy)

#Make sure we try the AzureADPreview module first, as it surfaces more details...
Remove-Module AzureAD -ErrorAction SilentlyContinue
Expand Down
2 changes: 1 addition & 1 deletion Groups_Owner_InventoryV2.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 3.0
#Requires -Version 3.0
#Requires -Modules @{ ModuleName="ExchangeOnlineManagement"; ModuleVersion="3.0.0" }
#Requires -Modules @{ ModuleName="Microsoft.Graph.Groups"; ModuleVersion="1.19.0" }
#Requires -Modules @{ ModuleName="Microsoft.Graph.Users"; ModuleVersion="1.19.0" }
Expand Down
Loading

0 comments on commit 96b62b2

Please sign in to comment.