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 Automate
Suggested Answer

run powershell script

(1) ShareShare
ReportReport
Posted on by 353

I'm trying to run the below powershell script in desktop, but after running the flow nothing seems to happen. It runs, then ends without error.  
The script executes correctly in Powershell. 

Ultimately I won't need to export the csv, but drop the data in a dataverse table, or failing that upload the csv to sharepoint then have a cloud flow process the file and drop it in dataverse.

 

 

#Connect to Exchange Online
Connect-ExchangeOnline -ShowBanner:$False
 
#Set Date Filters - past 24 hours!
$StartDate = (Get-Date).AddDays(-1)
$EndDate = Get-Date
 
#Filter Audit log to Find specific operations
$SiteURLs = @("https://company.sharepoint.com/")
$CSVFile = "C:\Temp\AuditLog1.csv"
$FileAccessOperations = @('PageViewed')
$SharePointLog = Search-UnifiedAuditLog -StartDate $StartDate -EndDate $EndDate -Operations $FileAccessOperations -ResultSize 5000 -ObjectIds $SiteURLs
$AuditLogResults = $SharePointLog.AuditData | ConvertFrom-Json | Select CreationTime,UserId,Operation, ObjectID,SiteUrl,SourceFileName,ClientIP

#Export Audit log results to CSV
$AuditLogResults
$AuditLogResults | Export-csv -Path $CSVFile -NoTypeInformation
 
#Disconnect Exchange Online
Disconnect-ExchangeOnline

 

 



I have the same question (0)
  • MS-08081525-0 Profile Picture
    3 on at
    Hello nick9one1,
     
    I am experiencing the same issue, a script which runs and creates a CSV file within PowerShell does not create a CSV file in PowerAutomate desktop.  Were you able to resolve this or find a workaround?
     
    Thanks,
  • Suggested answer
    eetuRobo Profile Picture
    4,574 Super User 2026 Season 1 on at
    @MS-08081525-0
     
    Enable ScriptError -variable from the Variables produced inside the Run PowerShell script -action.
     
     
    Then it should return ScriptError -variable that gives you information what went wrong.
    You can post the ScriptError output here so we can help figure out what is wrong.
     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 229 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 227

#3
Haque Profile Picture

Haque 181

Last 30 days Overall leaderboard