Forum Discussion
rich_russell
Sep 26, 2023Copper Contributor
How to open an Excel workbook from Sharepoint folder, with credentials
I've got a Powershell script that successfully opens and reads an Excel workbook which is stored in a Sharepoint folder, BUT when I set it up to run under Task Scheduler it fails. Note that when I ...
rich_russell
Sep 26, 2023Copper Contributor
Not to my knowledge. And if it were, wouldn't that prohibit the script from successfully accessing the workbook when I run it from the PS command prompt?
Thanks for any insight--conditional access policies and MFA are not something I'm familiar with.
Thanks for any insight--conditional access policies and MFA are not something I'm familiar with.
Sep 26, 2023
"Note: when running from command prompt the script DID prompt me for authentication the first time I ran it, but not since." The Scheduled Task doesn't run as your account I presume?
- rich_russellSep 26, 2023Copper ContributorGood question--thanks. It runs as the server's admin account, and the deal is:
That's an admin account on that domain, while the credentials used in the script to connect to the Power BI service are for a service account in a different domain. (Sorry if that's unclear--it's definitely ugly, but out of my control.) Bottom line: I can't run the script under the email/what3ver credentials (which have authority to read to the Excel workbook) and I can't use the credentials under which the script runs to access the Excel workbook.
But your question highlights the ridiculousness of that position! So maybe I can find some way to resolve that, and this problem would go away.- Oct 15, 2023Any update?
- Sep 26, 2023You can connect to PowerBI using an App Registration (https://learn.microsoft.com/en-us/powershell/module/microsoftpowerbimgmt.profile/connect-powerbiserviceaccount?view=powerbi-ps#example-4). But that's just getting the data, saving it to SharePoint site is something else, perhaps a ServicePrincipal would be better but don't have any experience in using that for this purpose (yet 😉 )