cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jakuza90
Level: Powered On

Runbook output to SharePoint

Working on a flow to automate reporting and need some help.

Here's what I'm trying to do:

 

Schedule recurrence > Run a Runbook from Azure Automation (Which is a Powershell script that pulls a list of all users) > Create a file in SharePoint with the output > Send a message to Teams or Email

 

I know there are a lot of moving parts here, I was wondering if my Powershell script needed to include some sort of Export-CSV or if Flow would be able to do something like "Write output from script to a csv file"

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

Hi @abm Thanks for your help. I was able to figure this out. I did a ConvertTo-JSON at the end of my script, and then from there I was able to do a Parse JSON > Create CSV Table > Create File.

 

Now I just need to figure out how to make it a XLSX instead of a CSV.

image.png

View solution in original post

14 REPLIES 14
Super User
Super User

Re: Runbook output to SharePoint

Hi @Jakuza90 

 

Run a Runbook from Azure Automation (Which is a Powershell script that pulls a list of all users)

 

Here you can use Flow action Azue Automation - Create Job

 

See this post

https://danielchronlund.com/2018/11/18/start-your-azure-automation-powershell-runbook-with-a-microso...

 

image.png

Create a file in SharePoint with the output

There is a Get job output flow action in Azure Automation. Using the output you should be able to create the file in SharePoint

 

Send a message to Teams or Email

Once the file is created in SharePoint you should be able to send email or team

 

image.png

 

image.png

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

So you're saying that I can just do Recurrence > Get job output from Azure Automation < Create File ?

What would I put for the Job ID in Get Job ouput? Also, how does Flow know to create a CSV file in SharePoint?

Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

I'm kind of stuck on when I do Create Job with Azure automation. Not sure what the parameter should be?

Super User
Super User

Re: Runbook output to SharePoint

Hi @Jakuza90 

 

Unfortunately I don't have a setup to test this. You could get the job Id from the create job properties? 

 

So to create the CSV file I was thinking use the output of the job action step and construct a csv file. 

 

Try using Create CSV table.

 

image.png



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

I'm sure if I can figure out what to put in the Runbook Parameter field I can figure this out.

image.png

Super User
Super User

Re: Runbook output to SharePoint

Hi @Jakuza90 

 

Thanks for your quick reply. Looks like that is an optional parameter where you can pass a value to the job. In your case it may not needed.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

Looks like the next issue is just outputting to a CSV. Not able to select the contents from Get job output as a CSV table. 

 

Here's my command on the runbook:

 

Get-UnifiedGroup -Identity * |Format-Table -Expand Both -Property PrimarySMTPAddress,ResourceProvisioningOptions,Hiddenfromaddresslistsenabled,HiddenFromExchangeClientsEnabled,ManagedByDetails
 
Not sure if I'm suppose to make it a variable and export to csv or something?
Super User
Super User

Re: Runbook output to SharePoint

Hi @Jakuza90 

 

What's the format of output? Could you please post a run history values?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

So I removed the "Format-Table" portion of the code. It now is just:

 

Get-UnifiedGroup -Identity * | Select-Object PrimarySMTPAddress,ResourceProvisioningOptions,Hiddenfromaddresslistsenabled,HiddenFromExchangeClientsEnabled,ManagedByDetails
 
Just trying to figure out how I can transform that output to a Csv
 
I tried turning that command into a variable and a doing Write-OutPut $variable but not sure how to take that to Flow
Super User
Super User

Re: Runbook output to SharePoint

Hi @Jakuza90 

 

Thanks for your quick reply.

 

image.png

 

When you run the flow is that first step return anything? If not what you getting from Get job output?

 

Apologies I don't have a  Azure job setup here otherwise I could have tried from my end.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

This is the output on a successful run for Get Job OutPut

 

image.png

Super User
Super User

Re: Runbook output to SharePoint

Hi @Jakuza90 

 

Thanks for your reply.

 

Is this works for you?

 

Get-UnifiedGroup -Identity * | Select-Object PrimarySMTPAddress,ResourceProvisioningOptions,Hiddenfromaddresslistsenabled,HiddenFromExchangeClientsEnabled,ManagedByDetails | export-csv your-file-name.csv

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Super User
Super User

Re: Runbook output to SharePoint

Hi @Jakuza90 

 

I have found this post and may be helpful for you.

 

https://powerusers.microsoft.com/t5/Building-Flows/Using-Output-from-Azure-runbook-get-job-output-fl...

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Jakuza90
Level: Powered On

Re: Runbook output to SharePoint

Hi @abm Thanks for your help. I was able to figure this out. I did a ConvertTo-JSON at the end of my script, and then from there I was able to do a Parse JSON > Create CSV Table > Create File.

 

Now I just need to figure out how to make it a XLSX instead of a CSV.

image.png

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Coming Soon: T-shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors
Users online (6,457)