How to get a Document URL via PowerShell & SharePoint Online
How to get a Document URL via PowerShell & SharePoint Online
(OP)
I have roughly 1000 files located in SharePoint that I need to query to produce a report of file name and the URL for the file. We are using SharePoint Online and I have been testing with the PNP model.
My company has 2 Factor Authentication enabled, so I need to use the -UseWebLogin method to connect.
I have been able to retrieve document GUIDs in the library I want the URLs for, but have been unable to find a way to reverse engineer the URLs witht he GUID or any other properties. Has anyone else found a solution to this?
Here is what I have so far:
And the output the above produces output like this (truncated for brevity):
I hope that helps.
Regards,
Mark
No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.
Work SMARTER not HARDER.
My company has 2 Factor Authentication enabled, so I need to use the -UseWebLogin method to connect.
I have been able to retrieve document GUIDs in the library I want the URLs for, but have been unable to find a way to reverse engineer the URLs witht he GUID or any other properties. Has anyone else found a solution to this?
Here is what I have so far:
CODE --> 5.1
# Load References [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null # Global Variables $siteUrl = "https://mytennant.sharepoint.com/sites/TechSupport/" $listName= "Tech Support Symptoms Index" # Credentials Connect-PnPOnline -Url $siteUrl -UseWebLogin Write-Host "The script is now running. Please avoid exiting to prevent incomplete results." -ForegroundColor Cyan # Get All List Items $listItems = Get-PnPListItem -List $listName # Traverse List Items foreach ($item in $listItems) { If($item.FieldValues.Domain = "TS Tandem OP") { $item.FieldValues.GUID.ToString() } }
And the output the above produces output like this (truncated for brevity):
CODE --> Output
c5c8fd46-9c0d-4ccf-94a8-cb549cfc3796 09c88000-4c6d-48bc-a8f7-d838f608bde6 6fc15ac1-7b27-49ed-9e81-3de544df261a e882724e-c04a-4c3a-973d-cbce4458bd2f 67d65189-7976-414f-bb3f-d788ad7ca7ff 9dc0689d-82ca-401b-8b19-dbac5fed5eaa 29284cba-3449-4443-9626-c18662ca9980 ea486235-99f9-43c2-85c9-29964646d0ba 2a39cdeb-70f7-4763-abb4-498d25ea5b34 aed593a5-fe10-44af-b231-f84eebfd52e5 d9884e82-1436-44f8-9723-adb70b22435e
I hope that helps.
Regards,
Mark
No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.
Work SMARTER not HARDER.