Solved

multiple file output powershell

Posted on 2016-10-28
7
59 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 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

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.

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 …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 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