Solved

multiple file output powershell

Posted on 2016-10-28
7
25 Views
Last Modified: 2016-10-28
I have a script that goes out and gets the folder ACL's recursive, however, the files are getting quite large..is there a way to make it cap at a certain file size then create new?
$ErrorActionPreference = "Continue" 
$strComputer = $env:ComputerName 
$colDrives = Get-PSDrive -PSProvider Filesystem 
ForEach ($DriveLetter in $colDrives) { 
    $StartPath = "E:\Share" 
    Get-ChildItem -LiteralPath $StartPath -Recurse | 
    ForEach { 
      $FullPath = Get-Item -LiteralPath (Get-Item -LiteralPath $_.PSPath) 
      (Get-Item -LiteralPath $FullPath).GetAccessControl() | 
      Select * -Expand Access | 
      Select @{N='Server Name';E={$strComputer}}, 
             @{N='Full Path';E={$FullPath}}, 
             @{N='Type';E={If($FullPath.PSIsContainer -eq $True) {'D'} Else {'F'}}}, 
             @{N='Owner';E={$_.Owner}}, 
             @{N='Trustee';E={$_.IdentityReference}}, 
             @{N='Inherited';E={$_.IsInherited}}, 
             @{N='Inheritance Flags';E={$_.InheritanceFlags}}, 
             @{N='Ace Flags';E={$_.PropagationFlags}}, 
             @{N='Ace Type';E={$_.AccessControlType}}, 
             @{N='Access Masks';E={$_.FileSystemRights}} } | 
      Export-CSV -NoTypeInformation -Delimiter "|" –Path "$strComputer`_$DriveLetter.csv" }

Open in new window

0
Comment
Question by:leadtheway
  • 4
  • 2
7 Comments
 
LVL 17

Expert Comment

by:contactkarthi
ID: 41864079
try using -maxsize
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41864095
where would it go?
0
 
LVL 12

Expert Comment

by:Dustin Saunders
ID: 41864272
So far as I know Export-CSV doesn't have the -MaxSize parameter.  You'd probably need to re-write the end of the script to Export-CSV -Append and then update the output file name each time by checking it's size and moving to the next file when it's size has been reached.

With some re-writes you could have it export a csv for each drive root folder.  It seems to me just splitting it on file size is going to make it hard to use efficiently.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 1

Author Comment

by:leadtheway
ID: 41864306
the way it is now will output per drive letter, problem is for a file server the list gets huge, over 1gb already
0
 
LVL 12

Accepted Solution

by:
Dustin Saunders earned 500 total points
ID: 41864356
Over 1GB in CSV?  You're collecting a ton of information then, I don't think CSV is the right format.  Even if you split it into 20MB files that would be 50 different files, how would you efficiently use that for anything?

I think you might want to stand up a SQL Express instance and drop the information into SQL, where you can query it to get the information you need on demand.  You can have your script repopulate it every x duration to keep it current.
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41864437
maybe I need a script that just gives me what I'm looking for.. I just need the folder name and ACL
0
 
LVL 1

Author Comment

by:leadtheway
ID: 41864495
I think i need to go the SQL route..don't look like this is a good option
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Set OWA language and time zone in Exchange for individuals, all users or per database.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question