NetSPI / NetSPI/MicroBurst

Get-AzDomainInfo throwing Illegal characters in path.

Open
#34 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
2.4k
Forks
340
PR merge metrics
No merged PRs in 30d

Description

After running Get-AzDomainInfo -verbose I received an Illegal characters in path error for every time Get-AzDomainInfo tried to write any output:
image
This is because the subscription has pipes | in it's name and those are illegal characters for a folder name. To fix my issue I edited lines 173-176 of Get-AzDomainInfo.ps1 to the following code:

    $folderSubscription = $Subscription.replace('|','-')
    if(Test-Path $folder"\"$folderSubscription){}
    else{New-Item -ItemType Directory $folder"\"$folderSubscription | Out-Null}
    
    $folder = -join ($folder, "\", $folderSubscription)

Probably a better solution to catch all Illegal characters is remove any characters from [System.IO.Path]::GetInvalidFileNameChars() -join '' out of the folder name to prevent this issue in the future.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Get-AzDomainInfo.ps1 around lines 173-176 and reproduce the issue with Get-AzDomainInfo -verbose using a subscription name containing a pipe. Check how output folders are constructed and verify that the command completes and creates valid subscription directories without illegal path characters.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.