web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Error when reading fro...
Power Automate
Unanswered

Error when reading from CSV

(0) ShareShare
ReportReport
Posted on by 340

Hi guys,

 

I have a PowerShell script that basically pulls out each user and their assigned license from our partner portal. I had trouble getting the output in a runbook so thought I would try a desktop flow. This is the flow:

 

da1ve_0-1677554633781.png

 

This is the PowerShell script:

 

$ApplicationId = 'xxx'
$ApplicationSecret = 'xxx' | Convertto-SecureString -AsPlainText -Force
$TenantID = 'xxx'
$RefreshToken = 'xxx'
$ExchangeRefreshToken = 'xxx'
$credential = New-Object System.Management.Automation.PSCredential($ApplicationId, $ApplicationSecret)

$aadGraphToken = New-PartnerAccessToken -ApplicationId $ApplicationId -Credential $credential -RefreshToken $refreshToken -Scopes 'https://graph.windows.net/.default' -ServicePrincipal -Tenant $tenantID
$graphToken = New-PartnerAccessToken -ApplicationId $ApplicationId -Credential $credential -RefreshToken $refreshToken -Scopes 'https://graph.microsoft.com/.default' -ServicePrincipal -Tenant $tenantID

Import-Module MSOnline
Connect-MsolService -AdGraphAccessToken $aadGraphToken.AccessToken -MsGraphAccessToken $graphToken.AccessToken
$customers = Get-MsolPartnerContract -All
Write-Host "Found $($customers.Count) customers for $((Get-MsolCompanyInformation).displayname)." -ForegroundColor DarkGreen
$CSVpath = "%TempFile%"

foreach ($customer in $customers) {
Write-Host "Retrieving license info for $($customer.name)" -ForegroundColor Green
$licensedUsers = Get-MsolUser -TenantId $customer.TenantId -All | Where-Object {$_.islicensed}

foreach ($user in $licensedUsers) {
Write-Host "$($user.displayname)" -ForegroundColor Yellow
$licenses = $user.Licenses
$licenseArray = $licenses | foreach-Object {$_.AccountSkuId}
$licenseString = $licenseArray -join ", "
Write-Host "$($user.displayname) has $licenseString" -ForegroundColor Blue
$licensedSharedMailboxProperties = [pscustomobject][ordered]@{
CustomerName = $customer.Name
DisplayName = $user.DisplayName
Licenses = $licenseString
TenantId = $customer.TenantId
UserPrincipalName = $user.UserPrincipalName
}
$licensedSharedMailboxProperties | Export-CSV -Path $CSVpath -Append -NoTypeInformation
}
}

#***End of script***

 

The flow is failing on step 3

 

da1ve_1-1677554716073.png

 

Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException: Import failed. Error while parsing ---> System.ArgumentException: Illegal characters in path.
 at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths)
 at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
 at System.IO.Path.GetFullPathInternal(String path)
 at Microsoft.VisualBasic.FileIO.FileSystem.NormalizePath(String Path)
 at Microsoft.VisualBasic.FileIO.TextFieldParser.ValidatePath(String path)
 at Microsoft.VisualBasic.FileIO.TextFieldParser.InitializeFromPath(String path, Encoding defaultEncoding, Boolean detectEncoding)
 at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.ReadFromCSVFileAction.Execute(ActionContext context)
 --- End of inner exception stack trace ---
 at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.ReadFromCSVFileAction.Execute(ActionContext context)
 at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

 

What are the illegal characters?

 

Thanks,
David

I have the same question (0)
  • OkanMTL Profile Picture
    703 Super User 2024 Season 1 on at

    Hi,

     

    Not sure if TempFile is a valid filepath. This action creates a file (not sure if it creates a filepath or where this filepath is).

     

    The action read CSV asks for a filepath. 

     

    Can you try:

    Making an empty CSV file outside PowerAutomatide in Excel or Notes? Save it and use the Saved FilePath as input for action 3, you can Delete action 1 then.

     

    Good luck.

  • Kaif_Siddique Profile Picture
    2,108 Super User 2024 Season 1 on at

    Hi @da1ve ,

     

    Try to remove the double quotes (")

    Kaif_Siddique_0-1677609566914.png

     

    If I have answered your question, please mark my post as Solved.

    If you like my response, please give it a Thumbs Up.

     

    Regards

    Kaif

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 382

#2
Valantis Profile Picture

Valantis 370

#3
David_MA Profile Picture

David_MA 300 Super User 2026 Season 1

Last 30 days Overall leaderboard