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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.