Old situation: I have a .bat file that copies some files and then starts a powershell with a given script. This script will boot up PowerBI and will do some query and exporting then from PowerBI. This works fine when fired up by taskscheduller when a user is logged on and only locked their PC.
Current situation: I'm moving to a Windows server instead of a separate computer with Windows desktop. I copied the task to the server and changed it to "run whether user is logged on or not".
I noticed if I force "run" on the task scheduler, it runs is some hidden mode (although I did not check the Hidden checkbox) so I don't see PowerBI get started. I assume it doesn't, as my powershell script fails further along the line where it needs to find its data in powershell.
log_message "***********************************************" log_message "Executing PBI_Exporter.ps1 at $($executionDate)" log_message "Launching Power BI" $template = "C:\LiveData\Eisen.pbix" $PBIDesktop = "C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe" $app = START-PROCESS $PBIDesktop $template -PassThru log_message "Waiting $($waitoPBD) seconds for PBI to launch" Start-Sleep -s $waitoPBD log_message "Assuming PBI is launched and ready now" $pathtofile = (Get-ChildItem -Path c:\users -Filter msmdsrv.port.txt -Recurse -ErrorAction SilentlyContinue -Force | sort LastWriteTime | select -last 1).FullName $port = gc $pathtofile $port = $port -replace '\D','' $dataSource = "localhost:$port" $pathtoDataBase_Name = $pathtofile -replace 'msmdsrv.port.txt','' $Database_Name = Get-ChildItem -Path $pathtoDataBase_Name -Filter *.db.xml -Recurse -ErrorAction SilentlyContinue -Force $Database_Name = $Database_Name.ToString().Split(".") | select -First 1
I can confirm the powershell script at least gets executed, as I can see the log file getting created, and it runs till the message where it assumes PowerBI is launched. Right after that I get an error Cannot bind argument to parameter 'Path' because it is null. so I assume that it's null because powerBI isn't executed.
Is there some way to confirm this (maybe some try/catch blocks?) and/or solve this?