[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

multiple file output powershell

Posted on 2016-10-28
7
Medium Priority
?
99 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 13

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
Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

 
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 13

Accepted Solution

by:
Dustin Saunders earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

656 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