So I have to automate a process that downloads an excel file from Microsofts Planner website. I have tried doing this 3 Different ways and have always hit a dead end. The only solution that seems to work is a script that imitates keypresses but is considered "bad practice" at my workplace.
First was obviously to use Microsoft Graph. It doesn't work because it would have to request for permissions from our companys MS ADMIN every time it makes an request. So thats a no go.
Edit: As @Crowcoder tried to anwser the post, his solution does not work. For it to work we would have to register into Azure Active Directory and we currently don't use it. (We use the MS local AD).
Then I have tried using GnuWin32 (Wget for windows). Doesn't work as it requires you to login 2 times and you can only put in creditentials once (Or maybe you can ? -> Couldn't figure out how).
After that I have tried to use the command for powershell. That comes close but also requires me to login with a popup.
Edit: Here we see the anwser from @lit which does not fit either. I have tried the solution and it promts a Google chrome alert login, and then also the MS Planner login (but you can put your creditentials only once as shown in the code below this).
Export-PlannerUserContent -UserAadIdOrPrincipalName -username -ExportDirectory "C:\pathToExport"
And for the end part the only solution that seems to work is the last one where I imitate keyboard presses to download the file. How the program runs:
- Open up chrome(With a shortcut to MS planner website)
- imitate keyboard presses to open DEV Console (ctrl+shift+J)
- Imitate keyboard so that imputs text(Javascript) to click the login into planner (if it exists, if not the function returns an error and skips this part)
- Imitate keyboard so that it inputs JS function that finds the necesary button and opens/presses the download button.
- after that it selects the 2nd pland and downloads it aswell (Same imitation of a keyboard textinput).
While this solution is the only one that "Works" I have been told that I should find a different solution as the keyboard simulator is not a viable solution for our company because of strict policies we have. Another reason why it cannot be used is because im trying to make this script run on our server with a service account that has no GUI. So I hit some sort of a dead end there as well.
EDIT: So What i'm trying to do here is implement a "headless" chrome that would do what it does now but can't seem to find a break trough.
So my question is does anybody have any tips, pointers or suggestions for improving the existing solutions or creating alternative ones that would be more appropriate.
Would love to hear your opinions on what I should research or do. I would also like to note that most API Calls don't work without heavy proxy configuration which I would like to avoid if possible.