Sharepoint PowerShell Question

brett05

867-5309
Joined:
Apr 28, 2009
Posts:
27,226
Liked Posts:
4,579
Location:
Hell
Anyone a powershell user for sharepoint?

I am looking for a way to have Powershell look thru all of our sites and sub sites and pull to a csv file all documents with name, last modified, and size.

so our main site is sharepoint.company.com and we have subsites like sharepoint.company.com/its and /finance and /finance/debts and finance/credits
Any of the pages could have documents on them. so I am hoping what I would get in the end is something like:

sharepoint.company.com/its test.xlsx 11/2/2017 5 KB
sharpeoint.company.com/finance/debts debts.doc 11/3/3017 14 KB
 

LordKOTL

Scratched for Vorobiev
Joined:
Dec 8, 2014
Posts:
8,676
Liked Posts:
3,046
Location:
PacNW
My favorite teams
  1. Portland Timbers
  1. Chicago Blackhawks
Sorry man...about the only thing I've ever done in powershell was the Robocopy command for scripting a "copy newer than" for a backup in a win10 environment.

I hope someone can give you pointers on this.
 

ShiftyDevil

CCS Donator
Donator
Joined:
Apr 28, 2011
Posts:
7,276
Liked Posts:
4,663
My favorite teams
  1. Chicago Blackhawks
  1. Washington Huskies
I haven't touched powershell in....... I honestly don't know. And my company has completely moved away from sharepoint

If this were a nix environment I could help you, sorry.
 

brett05

867-5309
Joined:
Apr 28, 2009
Posts:
27,226
Liked Posts:
4,579
Location:
Hell
As long as it is not an attack, can someone post for me what SHifty wrote? Thx.
 

AussieBear

Guest
As long as it is not an attack, can someone post for me what SHifty wrote? Thx.

why? do u block ppl?

he wrote:

"I haven't touched powershell in....... I honestly don't know. And my company has completely moved away from sharepoint

If this were a nix environment I could help you, sorry."
 

brett05

867-5309
Joined:
Apr 28, 2009
Posts:
27,226
Liked Posts:
4,579
Location:
Hell
why? do u block ppl?

he wrote:

"I haven't touched powershell in....... I honestly don't know. And my company has completely moved away from sharepoint

If this were a nix environment I could help you, sorry."

I do. Management at CCS suggested it.

Thanks Shifty! :)
 

Ares

CCS Hall of Fame
Donator
CCS Hall of Fame '19
Joined:
Aug 21, 2012
Posts:
42,351
Liked Posts:
35,068
I do. Management at CCS suggested it.

Thanks Shifty! :)

Monk also replied...

He said:

"Flat Earth is real, don't believe these heathens!"

I totally get why you would block Monk.
 

Ares

CCS Hall of Fame
Donator
CCS Hall of Fame '19
Joined:
Aug 21, 2012
Posts:
42,351
Liked Posts:
35,068
As for the actual OP question.

I touch PowerShell very lightly for some of our file handling that is annoyingly manual so I can automate bits and pieces via PS scripts.

If I was given the task you described....

1. I would be looking to run my script from a place where I can navigate to all the Sharepoint directories.

2. I would hope that place is just one spot hosting all the Sharepoint files in question.

3. If not then I would need to explore either multiple scripts for each server hosting Sharepoint content or seeing if I could get network shares to all relevant directories on the Sharepoint servers and have my script explore the share directories.

4. PowerShell can with just default library get file name, date modified, and size.... those would just be object properties once you get your script in the context of a directory with files you want to pull info for.

I have a script that just does gci (Get Child-Item) on the directory I am running it in and it looks for files with specific extensions.

gci gets you a "files" object and you can do a foreach on every item in your "files" set and then write the 3 file properties to a CSV.

Writing to a CSV is something I've never done, but I would be shocked it if was difficult to figure out without just googling.

If you took this method you would just need to make sure you gci and loop on every set of files in your overall project... continuing to append to your CSV file until you have everything you need.

You could then script it to move/archive the CSV wherever it ought to go.

The main challenge is probably having or getting access to your Sharepoint hosting server(s) so you can script this.
 

brett05

867-5309
Joined:
Apr 28, 2009
Posts:
27,226
Liked Posts:
4,579
Location:
Hell
Monk also replied...

He said:

"Flat Earth is real, don't believe these heathens!"

I totally get why you would block Monk.

I haven't seen monk around here for like a year or more.
 

brett05

867-5309
Joined:
Apr 28, 2009
Posts:
27,226
Liked Posts:
4,579
Location:
Hell
As for the actual OP question.

I touch PowerShell very lightly for some of our file handling that is annoyingly manual so I can automate bits and pieces via PS scripts.

If I was given the task you described....

1. I would be looking to run my script from a place where I can navigate to all the Sharepoint directories.

2. I would hope that place is just one spot hosting all the Sharepoint files in question.

3. If not then I would need to explore either multiple scripts for each server hosting Sharepoint content or seeing if I could get network shares to all relevant directories on the Sharepoint servers and have my script explore the share directories.

4. PowerShell can with just default library get file name, date modified, and size.... those would just be object properties once you get your script in the context of a directory with files you want to pull info for.

I have a script that just does gci (Get Child-Item) on the directory I am running it in and it looks for files with specific extensions.

gci gets you a "files" object and you can do a foreach on every item in your "files" set and then write the 3 file properties to a CSV.

Writing to a CSV is something I've never done, but I would be shocked it if was difficult to figure out without just googling.

If you took this method you would just need to make sure you gci and loop on every set of files in your overall project... continuing to append to your CSV file until you have everything you need.

You could then script it to move/archive the CSV wherever it ought to go.

The main challenge is probably having or getting access to your Sharepoint hosting server(s) so you can script this.

So I do have access and it gets runs in the SharePoint Shell (Powershell). I can produce the sites and all the subpages of the site. The issue is that each page may or may not have documents on them. I'm looking for a script that would list them if found. (Sorry if that's confusing, I'm a super newbie to SharePoint). It's 2013 btw
 

Ares

CCS Hall of Fame
Donator
CCS Hall of Fame '19
Joined:
Aug 21, 2012
Posts:
42,351
Liked Posts:
35,068
So I do have access and it gets runs in the SharePoint Shell (Powershell). I can produce the sites and all the subpages of the site. The issue is that each page may or may not have documents on them. I'm looking for a script that would list them if found. (Sorry if that's confusing, I'm a super newbie to SharePoint). It's 2013 btw

I've never worked with PowerShell integrated into Sharepoint, only at the OS level.

From that Sharepoint shell, can you access all the back end directories?

Like a document exists on a page, but that literal document file is sitting in a folder on the Sharepoint server.... can you get to the directory where it is stored from your Sharepoint shell?
 

brett05

867-5309
Joined:
Apr 28, 2009
Posts:
27,226
Liked Posts:
4,579
Location:
Hell
Ares,

Thanks man.

As far as I know, the folder structure isn't like the OS folder structure. SO there isn't like D:\Collection Sites\ITS\Pages\Documents\word.docx
 

Ares

CCS Hall of Fame
Donator
CCS Hall of Fame '19
Joined:
Aug 21, 2012
Posts:
42,351
Liked Posts:
35,068
Ares,

Thanks man.

As far as I know, the folder structure isn't like the OS folder structure. SO there isn't like D:\Collection Sites\ITS\Pages\Documents\word.docx

Not within the Sharepoint application.... but all that content is sitting in OS folder structures on w/e server is hosting the Sharepoint instances.

We had to migrate our Sharepoint and one of my peer Managers simply went in and copied all the file contents from the server's folder structures and pasted them into his desktop, then uploaded them all to the new site because he doesn't have access to the back end of the new Sharepoint host server.

If you can RDP into your Sharepoint server you should be able to find those OS Level folder structures somewhere.
 

brett05

867-5309
Joined:
Apr 28, 2009
Posts:
27,226
Liked Posts:
4,579
Location:
Hell
Thanks again Ares.
Just got done checking and the files are not there like they are in a Windows OS. They are part of the SQL database that holds all this.

Im going to keep hunting as it has to be able to be pulled from PS I would imagine.
 

Top