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.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
notarat
Posts: 24
Last visit: Mon Feb 12, 2018 6:56 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. foreach ($faileditem in $failedItems){
  3.  $done = ($faileditem.CategoryInfo.reason)+","+($faileditem.CategoryInfo.targetname)
  4.  Add-Content c:\outputfiles\ScanErrors.txt -value $done
  5. }
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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for a more efficient way to pull information

Post by jvierra »

There are really no faster methods.
User avatar
notarat
Posts: 24
Last visit: Mon Feb 12, 2018 6:56 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked