I use a lot the ImportExcel module in PowerShell and it works great with local and locally synced files. I have few Teams/SharePoint library syncing with my OneDrive and I use something on these lines to import excel data and then manipulate them directly in PowerShell (paths, file names and links are fictitious):
$File = "C:\Users\Username\OneDriveFolder\File.xlsm"
$Sheet = "Sheet1"
$DataSet = Import-Excel -Path $File -WorkSheetname $Sheet -DataOnly -StartRow 2
$Data = "Example"
$Query = $DataSet.Where({$_.$Data -like $Data})
I was wondering if it is was possible to use a SharePoint URL instead of a local path for the -Path attribute since I would like to import data from an Excel that is located on a SharePoint but it is not synced to my OneDrive:
$File = "https://companygroup.sharepoint.com/sites/sitefolders/File.xlsm"
$Sheet = "Sheet1"
$DataSet = Import-Excel -Path $File -WorkSheetname $Sheet -DataOnly -StartRow 2
$Data = "Example"
$Query = $DataSet.Where({$_.$Data -like $Data})
If I try to do that, I get a file not found error:
'https://companygroup.sharepoint.com/sites/sitefolders/File.xlsm' file not found
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.4.1\Public\Import-Excel.ps1:118 char:21
+ throw "'$($Path)' file not found"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: ('https://company... file not found:String) [], RuntimeException
+ FullyQualifiedErrorId : 'https://companygroup.sharepoint.com/sites/sitefolders/File.xlsm' file not found
Is there a way to use the ImportExcel module like that? If it only works with local/locally synced files, is there an alternative to do what I would like to do?
Thanks