Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Power shell and [Expression.Error] 2 arguments were passed to a function which expects 1

Trying to create a automation flow for a scheduled refresh where data is getting fetched from Sharepoint Lists and later unpivoted in Power Query (which is working fine). In order to refresh the excel file, shell script opens the file and stays open for some time during which data gets refreshed and upon closing below MACRO script saves the excel file.

macro 1.png

 

The problem is that below message box needs responding to

error excel m.png


The code invokes a method using the wscript.shell object and works fine when you are logged into the system. Unfortunately we need to this run on an unattended system. However due to the security policy the screen lock kicks in. When that happens it is no longer possible to invoke the wscript.shell object. Below link. 

wsh - VBScript not working when PC is locked - Stack Overflow

 

prob.png

 

However, the commands to open the Excel file and then do a graceful shutdown using macro do not have this limitation

Can you please guide how to reolve this, perhaps any changes in Macros also to see what is causing the error message to appear. If that can be removed the automation should work fine i guess.

I am beginner trying to find the solution.

Thanks

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

The error code means that it need two parameters in one function.

In powershell we don't use commas to separate arguments. Each argument is separated by space in PowerShell. 

 

How do I pass multiple variables to a powershell function? - Stack Overflow

junit - Use a variable in PowerShell to pass multiple arguments to an external program - Stack Overflow

2 arguments were passed to a function which expect... - Microsoft Power BI Community


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Using office 365

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors