?
Solved

multiple file output powershell

Posted on 2016-10-28
7
Medium Priority
?
79 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
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 you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

764 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