Skip to content

Commit c396036

Browse files
authored
Revise usage examples for PowerShell scripts
Updated usage examples for various PowerShell scripts in the README file to improve clarity and consistency.
1 parent 4f219a0 commit c396036

1 file changed

Lines changed: 85 additions & 74 deletions

File tree

README.md

Lines changed: 85 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ Notice the PowerShell user agent given we are using API calls from PS
133133
Notice the MFA requirement error description, as expected.
134134
![Notice the MFA requirement](Azure%20Active%20Directory/docs/image-20250514-202748.png)
135135

136-
Use like so:
137136
```powershell
138137
.\get_az_token.ps1 -TenantId "xxx" -Username "you@foo.bar" -ClientId "yyy" -AcknowledgeAuthorizedTesting
139138
```
@@ -158,7 +157,6 @@ Uses AADinternals to run Eight security checks on the tenant.
158157
Performs a read-only analysis of the user-assignment scope for Microsoft Entra Conditional Access policies. The script resolves direct and transitive group memberships, active supported directory roles, policy inclusions and exclusions, and policy state, then explains why each policy targets, excludes, or does not target the specified user.
159158
The script does not calculate whether every policy will trigger during a specific authentication attempt. Conditional Access runtime conditions such as cloud application, device compliance, platform, location, user or sign-in risk, client type, and authentication flow require the Conditional Access What If tool or sign-in-log evidence.
160159

161-
Use like so:
162160
```powershell
163161
.\get_policies.ps1 -UserPrincipalName "foo@contoso.com" -OutputCsv ".\ConditionalAccessUserTargeting.csv"
164162
```
@@ -173,7 +171,6 @@ Microsoft Graph Command Line Tools must be granted. If not you will be prompted
173171
Demonstrates how a privileged Microsoft Graph administrator can programmatically create a user-specific delegated permission grant between a client service principal and Microsoft Graph, then assign the client application to the selected user. The delegated grant authorizes the application to call Microsoft Graph on behalf of that user, subject to the granted scopes and the user’s own effective permissions.
174172
This administrative workflow illustrates one mechanism that can be abused after a highly privileged identity or application is compromised. The script does not create a malicious application, perform consent phishing, obtain tokens, or independently bypass MFA. Because it modifies tenant consent and application assignments using highly privileged Graph permissions, it should be used only in an isolated lab or explicitly authorized administrative workflow.
175173

176-
Use like so:
177174
```powershell
178175
.\grant_consent_MSGraph.ps1 -ClientAppId "11111111-1111-1111-1111-111111111111"
179176
@@ -187,7 +184,6 @@ Use like so:
187184
Sends an authorized email through Microsoft Graph using app-only client-credentials authentication and the Mail.Send application permission. The script accepts configurable sender, recipient, subject, and message-body values, reads the application secret from an environment variable, supports a dry-run mode, and returns detailed Microsoft Graph errors without printing or storing access tokens.
188185
The Entra application must have the Microsoft Graph Mail.Send application permission with administrator consent. Because this permission can provide broad mail-sending capability, Exchange Online App RBAC should be used to restrict the application to approved sender mailboxes. An HTTP 202 Accepted response confirms that Microsoft Graph accepted the message for processing, but does not guarantee final delivery.
189186

190-
Use like so:
191187
```powershell
192188
$secureSecret = Read-Host "Enter the application client secret" -AsSecureString
193189
@@ -218,7 +214,6 @@ This read-only script audits Azure Storage accounts across all subscriptions acc
218214

219215
This script consumes the container CSV generated by Get-AzureStorageAnonymousAccess.ps1 and performs unauthenticated curl.exe tests against each applicable Blob container. It checks anonymous container enumeration and can optionally validate exact-object access using a one-byte range request when the CSV contains an ExactBlobName column.
220216

221-
Use like so:
222217
```powershell
223218
.\Test-AzureBlobAnonymousEndpoints.ps1 -InputCsv "C:\Users\mario\StorageContainerPublicAccessDetails-20260730-003512.csv"
224219
```
@@ -244,13 +239,14 @@ The script queries Microsoft Graph and therefore does not require a corporate ne
244239
---
245240
### `Get-DisabledUsersLicenses6.ps1`
246241

247-
Scans the tenant for disabled Microsoft 365 users via Microsoft Graph and resolves their assigned licenses into readable names.
248-
Outputs a formatted table and optionally exports a CSV; preserves dry‑run behavior so no changes are made unless explicitly requested.
242+
Scans Microsoft Entra ID for disabled users who still have assigned Microsoft licenses and resolves license SKU identifiers into readable product names. The script exports one row per user-license assignment, distinguishes direct licensing from group-based licensing, identifies the assigning group, and records assignment state and errors.
243+
An optional per-user summary consolidates each disabled account’s licenses and assignment methods for easier license-reclamation review. The script is completely read-only and does not modify users, groups, or license assignments.
249244

250-
Use like so:
251-
`Connect-MgGraph -Scopes "User.Read.All","Directory.Read.All" -UseDeviceAuthentication`
252-
253-
`.\Get-DisabledUsersLicenses6.ps1 -ExportCsv .\disabled_licenses.csv`
245+
```powershell
246+
.\Get-DisabledUsersLicenses6.ps1
247+
-ExportCsv ".\DisabledUserLicenseDetails.csv"
248+
-SummaryCsv ".\DisabledUserLicenseSummary.csv"
249+
```
254250

255251
---
256252
### `RemoveM365LicensesfromDisabledUsers3.ps1`
@@ -287,26 +283,27 @@ Prerequisites: An active Graph session (Connect-MgGraph) with User.ReadWrite.All
287283

288284
All scripts rely on the **[Microsoft.Graph PowerShell SDK](https://learn.microsoft.com/powershell/microsoftgraph/overview)**
289285
Before running the scripts, establish a Graph session with sufficient rights:
290-
Use like so:
291-
292-
`.\list_all_applications2.ps1` Generates CSV files
286+
```powershell
287+
.\list_all_applications2.ps1 //Generates CSV files
293288
294-
`.\BulkMultiPermExploitability2.ps1 -ScopeCsvPath ScopeBreakdown.csv` This parses previously generated CSV file
289+
.\BulkMultiPermExploitability2.ps1 -ScopeCsvPath ScopeBreakdown.csv //This parses previously generated CSV file
290+
```
295291

296292
When you see "Problem!" this is how you dig deeper into the app details
293+
```powershell
294+
.\Profile-App.ps1 -TargetAppId dddddd-ba25-43c7-a710-cxxxx
297295
298-
`.\Profile-App.ps1 -TargetAppId dddddd-ba25-43c7-a710-cxxxx`
299-
300-
`.\Audit-AppDelegationRisks.ps1 -TargetAppId dddddd-ba25-43c7-a710-cxxxx`
296+
.\Audit-AppDelegationRisks.ps1 -TargetAppId dddddd-ba25-43c7-a710-cxxxx
297+
```
301298

302-
---
303299
### `Audit-AllUsersRolePerms.ps1`
304300

305301
Tenant-wide audit of default user role permissions, privileged directory roles, and high-privilege Azure RBAC assignments—highlighting only users who exceed the locked-down defaults.
306302
Must have Graph API permissions Policy.Read.All to use this script
307303

308-
Use like so:
309-
`.\Audit-AllUsersRolePerms.ps1`
304+
```powershell
305+
.\Audit-AllUsersRolePerms.ps1
306+
```
310307

311308
---
312309
👉** automate creation of malicious-looking OAuth authorization flows (device‑code and consent URLs) used in consent‑phishing simulations **
@@ -330,15 +327,16 @@ Generates OAuth device‑code or authorization URLs and associated tracking arti
330327
Using Azure Hybrif Workers? Keep an eye on your Runbook without cikickety-clicking the portal.
331328
Will print out the Runbook logs.
332329

333-
Use like so:
334-
`.\watch_X_job3.ps1 -ResourceGroupName 'XXX-Hybrid-Automation' -AutomationAccountName 'XXX-Cybersecurity-Automation' -RunbookName pwned`
335-
330+
```powershell
331+
.\watch_X_job3.ps1 -ResourceGroupName 'XXX-Hybrid-Automation' -AutomationAccountName 'XXX-Cybersecurity-Automation' -RunbookName pwned
332+
```
336333
or
337-
338-
`$job = Start-AzAutomationRunbook -ResourceGroupName 'XXX-Hybrid-Automation' -AutomationAccountName 'XXX-Cybersecurity-Automation' -Name 'pwned' -RunOn 'xxxGroup'`
339-
340-
`.\watch_X_job3.ps1 -ResourceGroupName 'XXX-Hybrid-Automation' -AutomationAccountName 'XXX-Cybersecurity-Automation' -RunbookName pwned -JobId $job.JobId`
341-
334+
```powershell
335+
$job = Start-AzAutomationRunbook -ResourceGroupName 'XXX-Hybrid-Automation' -AutomationAccountName 'XXX-Cybersecurity-Automation' -Name 'pwned' -RunOn 'xxxGroup'
336+
```
337+
```powershell
338+
.\watch_X_job3.ps1 -ResourceGroupName 'XXX-Hybrid-Automation' -AutomationAccountName 'XXX-Cybersecurity-Automation' -RunbookName pwned -JobId $job.JobId
339+
```
342340

343341
---
344342
### `Inspect-AzWebAppSecurity-Consolidated.ps1`
@@ -352,8 +350,9 @@ Will check Web app for things like:
352350
- Defender
353351
- WAF etc...
354352

355-
Use like so:
356-
`.\Inspect-AzWebAppSecurity-Consolidated.ps1 -SubscriptionId xxx -ResourceGroup "yyy" -AppName "zzz" `
353+
```powershell
354+
.\Inspect-AzWebAppSecurity-Consolidated.ps1 -SubscriptionId xxx -ResourceGroup "yyy" -AppName "zzz"
355+
```
357356

358357
---
359358
### `Audit-NeverSucceedingMailForwardingRules.ps1`
@@ -374,8 +373,6 @@ It checks for things like:
374373

375374
Useful for identifying stale mailbox rules, broken forwarding logic, and forwarding-related exfiltration risk. Microsoft documents that Inbox rules can forward or redirect mailbox messages, and Microsoft also warns that automatic forwarding can be abused after account compromise for data disclosure/exfiltration.
376375

377-
Use like so:
378-
379376
```powershell
380377
.\Audit-NeverSucceedingMailForwardingRules.ps1 -OutputDirectory . -IncludeReviewWarnings
381378
```
@@ -399,8 +396,6 @@ This script is useful for identifying stale, orphaned, or risky Teams that may n
399396

400397
The script does **not** delete, archive, or modify any Teams.
401398

402-
Use like so:
403-
404399
```powershell
405400
.\Review-TeamsLifecycleCleanupCandidates.ps1
406401
```
@@ -435,8 +430,6 @@ This script is useful for reviewing stale B2B/guest accounts before disabling or
435430

436431
The script does **not** block, delete, or modify users.
437432

438-
Use like so:
439-
440433
```powershell
441434
.\Report-InactiveGuestUsers-150Days.ps1
442435
```
@@ -447,8 +440,9 @@ Use like so:
447440

448441
Audits Active Directory permissions for a given user and all the groups they belong to, within a specified LDAP container. It reports every Access Control Entry (ACE) that grants the user or their groups any rights on objects under the search base.
449442

450-
Use like so:
451-
`.\ad_object_permissions3.ps1 -Username "XXX\mcontestabile" -Domain "DC=YYYYYY,DC=net"`
443+
```powershell
444+
.\ad_object_permissions3.ps1 -Username "XXX\mcontestabile" -Domain "DC=YYYYYY,DC=net"
445+
```
452446

453447
Each row in the output indicates a single permission grant:
454448
- ObjectDN
@@ -467,8 +461,9 @@ Keep an eye out for anything that shows
467461

468462
Audits explicit ACLs for a single account under a given AD container. It dumps every Access Control Entry (ACE) on objects beneath your search base where the ACE’s IdentityReference exactly matches the provided username.
469463

470-
Use like so:
471-
`.\delegated_rights.ps1 -Username "XXX\mcontestabile" -Domain "DC=YYYYYY,DC=net"`
464+
```powershell
465+
.\delegated_rights.ps1 -Username "XXX\mcontestabile" -Domain "DC=YYYYYY,DC=net"
466+
```
472467

473468
---
474469
### `servers_get_smb.ps1`
@@ -493,8 +488,9 @@ Lists members of the local Administrators group on the machine where the script
493488

494489
Tests AD accounts for blank or username-equal passwords and reports results.
495490

496-
Use like so:
497-
`.\check_blank_password_users.ps1 -DomainFqdn domain.net`
491+
```powershell
492+
.\check_blank_password_users.ps1 -DomainFqdn domain.net
493+
```
498494

499495
---
500496
### `check_PSSession_blank_passwords2.ps1`
@@ -516,8 +512,9 @@ For each domain joined computer, use WMI to check SMB settings.
516512

517513
Finds enabled Active Directory users inactive for a specified number of days (default: 180), excluding the built-in Administrator account.
518514

519-
Use like so:
520-
`.\inactive_users.ps1`
515+
```powershell
516+
.\inactive_users.ps1
517+
```
521518

522519
---
523520
### `is_ldap_signing_enabled.ps1` (Requires PS version 7)
@@ -538,10 +535,12 @@ Audits permissions on an Active Directory user object.
538535
- Outputs a table showing who holds the right, what object type it applies to, the kind of rights, and whether it’s Allow or Deny.
539536
Use this to verify special delegation or extended rights granted to a user against their own AD object.
540537

541-
Use like so:
542-
`.\replicate_permissions.ps1 -UserName "XXX\yyy"`
543-
544-
`.\replicate_permissions.ps1 -UserName "mario@xxx.net"`
538+
```powershell
539+
.\replicate_permissions.ps1 -UserName "XXX\yyy"
540+
```
541+
```powershell
542+
.\replicate_permissions.ps1 -UserName "mario@xxx.net"
543+
```
545544

546545
---
547546
### `replicated_rights2.ps1`
@@ -552,16 +551,18 @@ Identifies which AD objects include access control entries (ACEs) granting the t
552551
- WriteProperty
553552
- ExtendedRight
554553

555-
Use like so:
556-
`.\replicated_rights2.ps1 -UserAccountName 'XXX\krbtgt' -SearchBase 'DC=xxx,DC=yyy' -Verbose`
554+
```powershell
555+
.\replicated_rights2.ps1 -UserAccountName 'XXX\krbtgt' -SearchBase 'DC=xxx,DC=yyy' -Verbose
556+
```
557557

558558
---
559559
### `setNoPreauth.ps1`
560560

561561
Provides a controlled way to disable Kerberos pre-authentication for an Active Directory user by flipping a single bit in their userAccountControl attribute. It also gives you clear visibility into which flags are set on that user object both before and after the change. Modifying the userAccountControl attribute in Active Directory isn’t something a standard domain user can do by default. You'll get "Exception calling "SetInfo" with "0" argument(s): "Access is denied."
562562

563-
Use like so:
564-
`.\setNoPreauth.ps1 "LDAP://CN=Mario Contestabile,OU=blahblah,OU=bloop,DC=xxx,DC=yyy"`
563+
```powershell
564+
.\setNoPreauth.ps1 "LDAP://CN=Mario Contestabile,OU=blahblah,OU=bloop,DC=xxx,DC=yyy"
565+
```
565566

566567
---
567568
### `AD_Audit_Script.ps1` (Requires PowerSploit! Ergo better to use in PowerShell 5.1 (just run powershell.exe -Version 5.1).)
@@ -573,8 +574,9 @@ Creates a report file for you.
573574

574575
Audit powerful rights over GPOs. Inactive accounts are shown in red.
575576

576-
Use like so:
577-
`.\GpoAclAudit.ps1 -DomainName xxx.net`
577+
```powershell
578+
.\GpoAclAudit.ps1 -DomainName xxx.net
579+
```
578580

579581
---
580582
### `GetUsersAndTheirManagedByMachines.ps1`
@@ -627,18 +629,19 @@ This is a great tool to uncover secrets on a LAN. Corporations unknowingly share
627629
3. Private Keys
628630
4. Etc...a whole lot more
629631

630-
Use like:
631-
`.\lan_audit_full2.ps1 "\\somedc.somedomain.net\UNCName\Any Folders" audit_report.csv`
632+
```powershell
633+
.\lan_audit_full2.ps1 "\\somedc.somedomain.net\UNCName\Any Folders" audit_report.csv
634+
```
632635

633636
---
634637
### `CheckWritableAttributesADUsers.py|.ps1`
635638

636639
The Python svcript uses strictly LDAP3 to enumerate the AD users (use the -dc-ip parameter to specify your Domain Controller IP).
637640
Then it will attempt to write "temp" to attributes to determine if any is writeable.
638641
Although not the most elegent solution - it works! It will write a users.cvs file, which should only contain your own AD account-any others are worhty of ivestigation!
639-
Use like so:
640-
641-
`python3 CheckWritableAttributesADUsers.py DOMAIN/mcontestabile:'XXX' -dc-ip 1.2.3.4`
642+
```powershell
643+
python3 CheckWritableAttributesADUsers.py DOMAIN/mcontestabile:'XXX' -dc-ip 1.2.3.4
644+
```
642645

643646
The PowerShell version does the same thing - but with a twist.
644647
Firstly, it will try to use ADWS first before falling back to LDAP.
@@ -712,27 +715,33 @@ Run this from where we have some "security filtering" in place and get a good id
712715
---
713716
### `Base64Tool.ps1`
714717

715-
Use like so:
716-
717-
`.\Base64Tool.ps1 -InputString 'SGVsbG8gV29ybGQh'`
718-
719-
(Equivalent to `[Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('SABlAGwAbABvACAAVwBvAHIAbABkACEA'))`)
720-
721-
`.\Base64Tool.ps1 -InputString 'Hello World!' -Encode`
718+
```powershell
719+
.\Base64Tool.ps1 -InputString 'SGVsbG8gV29ybGQh'
720+
```
722721

723-
(Equivalent to `[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes('Hello World!'))`)
722+
Equivalent to
723+
```powershell
724+
[Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('SABlAGwAbABvACAAVwBvAHIAbABkACEA'))
725+
.\Base64Tool.ps1 -InputString 'Hello World!' -Encode
726+
```
727+
Equivalent to
728+
```powershell
729+
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes('Hello World!'))
730+
```
724731

725732
---
726733
### `domains2ipsipv4Only.ps1`
727734

728735
Given a list of domain will provide DNS info. I use it in combination with the domains in a tenant to get info on them (is it on wix, aws, etc..)
729736

730-
Use like so, first get domains from tenant:
731-
`az rest --method GET --uri "https://graph.microsoft.com/v1.0/domains" --headers "Content-Type=application/json" --query "value[].{Name:id,IsVerified:isVerified,AuthType:authenticationType}" -o table > all_domains.txt`
732-
737+
First get domains from tenant:
738+
```powershell
739+
az rest --method GET --uri "https://graph.microsoft.com/v1.0/domains" --headers "Content-Type=application/json" --query "value[].{Name:id,IsVerified:isVerified,AuthType:authenticationType}" -o table > all_domains.txt
740+
```
733741
Results piped to all_domains.txt which we will feed into the script like so:
734-
735-
`.\domains2ipsipv4Only.ps1 -InputPath all_domains.txt -OutputPath ips.txt`
742+
```powershell
743+
.\domains2ipsipv4Only.ps1 -InputPath all_domains.txt -OutputPath ips.txt
744+
```
736745

737746
---
738747
### `DisableWindowsDefender.ps1`
@@ -759,7 +768,9 @@ Set interface metrics for physical adapters only.
759768
- Use -Trial to preview planned changes without applying them
760769

761770
Use like so to see what changes it will perform without applying them:
762-
`.\SetAdaptorMetricWired_Highest.ps1 -Trial`
771+
```powershell
772+
.\SetAdaptorMetricWired_Highest.ps1 -Trial
773+
```
763774

764775
---
765776
### `Check-ModularDS.ps1`

0 commit comments

Comments
 (0)