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 / Calling a Powershell s...
Power Automate
Unanswered

Calling a Powershell script with a PowerAutomate flow

(0) ShareShare
ReportReport
Posted on by 51

 

I have built a Job, using the Job Agent, as well as a  SSIS packages within a local Server ( a Replica) using Microsoft SQL Management Studio, the Job has a Powershell script that , that via a REST API ( dot-walking technique) grabs info from ServiceNow  and posts the info into a CSV file. This whole system works fine and without any hiccups.

We need to " convert" this methodology into a Power Automate flow ( Cloud flow), the first hiccup I found was, how to have an Action to execute a Powershell script with the PowerAutomate flow, without using Premium connectors, or mechanism whereby I need an expensive Azure subscription.

Could someone help me to find out whether it is possible to create this PowerAutomate flow calling the (Action) a Powershell script?

My Powershell script ( currently working fine. User and password removed) is:

$user = "xxxxxxxxx.scorecard.service"
$pass = "$$$$$$$$$$$$$$$$"


# Build auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))

# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo))
$headers.Add('Accept','application/json')


# Specify endpoint uri
$url_base = "https://xxxxxxxxx.service-now.com/api/now/table/x_lsmcb_fm_room"
#$url_endpoint = "?sysparm_query=id=SPL_13-0.020&sysparm_fields=u_specification,u_function,name,id,type.value,display_name,gla,capacity,fm_location.full_name"
# Only non-empty IDs
$url_endpoint = "?sysparm_query=idISNOTEMPTY&sysparm_fields=u_specification,u_function,name,id,type.value,display_name,gla,capacity,fm_location.full_name"
$uri = $url_base + $url_endpoint

# Specify HTTP method
$method = "get"
$contentType = "application/xml"
$ExportFolder = "Filesystem::C:\DBA\scripts\P\Scorecard\"
$ExportFile = "Export_Ruimtes.csv"
$ExportPath = Join-Path $ExportFolder $ExportFile
$Ruimteslist = @()


Function Get-Mobilenummers
{

# Change any TLS protocol

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

# Invoke-RestMethd to get the Contents
$MN_response = Invoke-RestMethod -Headers $headers -Method $method -Uri $uri -ContentType $contentType

#Loop trough into an ordered hash table
foreach ($item in $MN_response.result)
{

$Ruimteslist = [ARRAY]$Ruimteslist + [PSCustomObject] @{

Naam = $item.'name'
Ruimtenummer = $item.'id'
Type = $item.'type.value'
Vestiging = $item.'fm_location.full_name'
Gebruiksfunctie = $item.'u_function'
Specificatie = $item.'u_specification'
Capaciteit = $item.'capacity'
Vloeroppervlakte = $item.'gla'
Verhuurbaar_oppervlakte = $item.'gla'
Bruto_vloeroppervlakte = 0

}

 

}

# Return the full hash table

Return $Ruimteslist
}

$Ruimteslijst = Get-Mobilenummers

# Export the list to a CSV file

$Ruimteslijst| ForEach-Object{ [pscustomobject]$_ } | Export-CSV -Path $ExportPath -NoTypeInformation -Delimiter ";" -Encoding utf8 -Force

Categories:
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Argy_Zadkine 

     

    I could see some premium connectors for running powershell script.

     

    You can try desktop flows action via desktop flow, you can run powershell script. 

     

    Other way would be to convert the powershell script into complete power automate cloud flow.

     

    I hope your powershell script is pulling records from servicenow API and adding it to csv table.

    So you can replicate same via powerautomate actions like calling API and csv related operations 🙂

     

    Hope this information helps

     

    Mark it as solution if it resolves your query 🙂

     

  • Argy_Zadkine Profile Picture
    51 on at

    Thanks, Nived_Nambiar for your reply. Let me answer your points:

    1. I am aware that there are Premium Connectors that could do the trick, however , I am NOT interested in using Premium Connectors.  

    2. I am not using Desktop flows, I am using Power Automate Cloud flows

    3. Could you please elaborate on your statement: "Other way would be to convert the powershell script into complete power automate cloud flow. "  How could you " Convert" a Powershell script into PowerAutomate cloud flow  actions? I have attached my Powershell script in my original post, could you please help me with some hints or suggestions?

    4. Your last statement: "I hope your powershell script is pulling records from servicenow API and adding it to csv table. " . Yes, my Powershell is using SeviceNow RestAPI statement to get data out of ServiceNow and poting the results in a CSV files. I still so not know how you could " Convert" Powershell script statements into Power Automate cloud flow actions ( see my original post)

    Thanks a lot for your contribution

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Argy_Zadkine 

     

    What i meant by 3rd question is since your power shell script is pulling data from service now using sharepoint and adding it to csv , you can convert the same to power automate actions like below

     

    1. Use HTTP action to call the service now api to pull records

     

    2. Use create csv table to create CSV table out of http request output

     

    3. Then create file out of that output from step 2

     

    Hope this idea helps you in developing complete flow

     

    Mark it as solution if it resolves your query 🙂

     

  • VictorIvanidze Profile Picture
    13,083 on at

    Hi @Argy_Zadkine,

    in short: yes that's possible  but only using a premium connector. 

  • Argy_Zadkine Profile Picture
    51 on at

    Thanks, Victor. I am looking for an option where no Premium connector is needed

  • Argy_Zadkine Profile Picture
    51 on at

    Thanks, Nived. Do you have a link to an example where this is achieved?

  • VictorIvanidze Profile Picture
    13,083 on at

    Hi @Argy_Zadkine, 

    no way, as far as I know, sorry. 

  • Argy_Zadkine Profile Picture
    51 on at

    Thanks. I have decided to use the ServiceNow Premium Connector. However, when using the ServiceNow Connector, I want to read records in a ServiceNow table at a given moment, nit via a Trigger. I am still trying to figure out how to use the Connector

  • Argy_Zadkine Profile Picture
    51 on at

    I will be using the ServiceNow Premium Connector

    Argy_Zadkine_0-1681798793899.png

    However to use this premium connector, I need to create a trigger and name the Connection. I  want to read records from a ServiceNow table ( as my original Powershell script says), with a set of parameters. I do have the URL for the ServiceNow connection, along with the Instance and the Credentials ( user, password). Is it possible to use the ServiceNow connector without a specific trigger? 

    ServiceNow connector for " List records" 

    Argy_Zadkine_1-1681798961078.png

    Thanks again for your help

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Argy_Zadkine 

     

    I did not get your question with respect to word trigger ?

     

    Could you please elaborate it better ?

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 288 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard