Looking for a more efficient way to pull information

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
notarat
Posts: 24
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Mon Aug 26, 2013 10:51 am

Looking for a more efficient way to pull information

Post by notarat »

I have a power shell script I use to scan my office's network drives for instances where my permissions have been removed, or where someone has saved a file, created a folder (or a combination of the two) where the length exceeds the 255 character limit.

(Please keep in mind I'm not a system admin so I don't have Admin permissions on the share. Some departments are allowed Full Control permissions on their shared drives, and they sometimes blow out permissions accidentally and I am forced to identify and submit tickets to get them fixed. Not a great environment, I know...but it is what it is and I have to deal with it)


My code is:
  1. $null=(Get-ChildItem W:\ -Recurse -Force -ErrorVariable FailedItems -ErrorAction SilentlyContinue)
  2.  
  3. foreach ($faileditem in $failedItems){
  4.  
  5.  $done = ($faileditem.CategoryInfo.reason)+","+($faileditem.CategoryInfo.targetname)
  6.  
  7.  Add-Content c:\outputfiles\ScanErrors.txt -value $done
  8.  
  9. }
This retrieves the information I need and outputs it into a text file for me but it is a bit slow, tbh, and I don't think it would be very useful in an enterprise environment on really really large shared drives. Can someone please suggest some alternative methods that are a bit more efficient/faster?

jvierra
Posts: 14448
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Looking for a more efficient way to pull information

Post by jvierra »

There are really no faster methods.

User avatar
notarat
Posts: 24
Joined: Mon Aug 26, 2013 10:51 am

Re: Looking for a more efficient way to pull information

Post by notarat »

Thanks for the response.

Dang...I was hoping there was a faster way :(

jvierra
Posts: 14448
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Looking for a more efficient way to pull information

Post by jvierra »

The issue is that only the exceptions are able to give you folders and that will not work correctly in your code although it may seem to

You can try using RoboCopy in logging mode and parse the log for the perms. I have never tried this but it would be much faster.

Locked