×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to get a Document URL via PowerShell & SharePoint Online

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:

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close