Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Need help with pulling dates, ACL permissions into a CSV file

Reply
 
Old 05-27-2008   #1 (permalink)
Ron


 
 

Need help with pulling dates, ACL permissions into a CSV file

All -

I am trying to use Powershell to get ACL's for me on files residing on
various servers. I need the command to run recursively from the root path
specified and get active acl permissions, fullpath/filename, modified date,
owner, and group membership. This way I should be able to get a CSV file for
files in directories ( and sub directories I specify.

I found a command (see link or below) in powershell on "Scripting Guy
forums" on http://www.microsoft.com/technet/scr...ps/ps/acl.mspx
has everything I need besides the last modified date of the file.

PS C:\> get-childitem c:\work –recurse | get-acl | select-object
path,owner,accesstostring,group | export-csv c:\ACL.csv

Any idea what parameter or switch I add to also list the modified date as
part of the CSV output? I have been trying to find resources to explain the
syntax better.
Please send me a complete command that works.

Thanks

Ron








My System SpecsSystem Spec
Old 05-27-2008   #2 (permalink)
Shay Levi


 
 

Re: Need help with pulling dates, ACL permissions into a CSV file


Hi

If you'll pipe this to get-member you'll see a property called pspath, its
how Windows PowerShell see the file path :

get-childitem c:\work | gm


You can translate this pspath to a file system path by using the Resolve-Path
cmdlet, then use get-childitem (dir) to get the lastWriteTime property of
each file and append it as a new coulmn (property) using a calculated property:

$lwt = @{n="LastWriteTime";e={ (dir (Resolve-Path $_.PSPath).ProviderPath).lastWriteTime
}}
get-childitem c:\work –recurse | get-acl | select-object path,owner,accesstostring,group,$lwt
| export-csv c:\ACL.csv


More on Calculated Properties:
http://www.microsoft.com/technet/scr...pstip0425.mspx

---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> All -
>
> I am trying to use Powershell to get ACL's for me on files residing on
> various servers. I need the command to run recursively from the root
> path specified and get active acl permissions, fullpath/filename,
> modified date, owner, and group membership. This way I should be able
> to get a CSV file for files in directories ( and sub directories I
> specify.
>
> I found a command (see link or below) in powershell on "Scripting Guy
> forums" on
> http://www.microsoft.com/technet/scr...ps/ps/acl.mspx has
> everything I need besides the last modified date of the file.
>
> PS C:\> get-childitem c:\work –recurse | get-acl | select-object
> path,owner,accesstostring,group | export-csv c:\ACL.csv
>
> Any idea what parameter or switch I add to also list the modified date
> as part of the CSV output? I have been trying to find resources to
> explain the syntax better. Please send me a complete command that
> works.
>
> Thanks
>
> Ron
>

My System SpecsSystem Spec
Old 05-27-2008   #3 (permalink)
Shay Levi


 
 

Re: Need help with pulling dates, ACL permissions into a CSV file


You can skip the path translation and let PowerShell resolve it:

$lwt = @{n="LastWriteTime";e={ (dir $_.PSPath).lastWriteTime }}


---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> Hi
>
> If you'll pipe this to get-member you'll see a property called pspath,
> its how Windows PowerShell see the file path :
>
> get-childitem c:\work | gm
>
> You can translate this pspath to a file system path by using the
> Resolve-Path cmdlet, then use get-childitem (dir) to get the
> lastWriteTime property of each file and append it as a new coulmn
> (property) using a calculated property:
>
> $lwt = @{n="LastWriteTime";e={ (dir (Resolve-Path
> $_.PSPath).ProviderPath).lastWriteTime
> }}
> get-childitem c:\work –recurse | get-acl | select-object
> path,owner,accesstostring,group,$lwt
> | export-csv c:\ACL.csv
> More on Calculated Properties:
> http://www.microsoft.com/technet/scr...pstips/apr08/p
> stip0425.mspx
> ---
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
Quote:

>> All -
>>
>> I am trying to use Powershell to get ACL's for me on files residing
>> on various servers. I need the command to run recursively from the
>> root path specified and get active acl permissions,
>> fullpath/filename, modified date, owner, and group membership. This
>> way I should be able to get a CSV file for files in directories ( and
>> sub directories I specify.
>>
>> I found a command (see link or below) in powershell on "Scripting Guy
>> forums" on
>> http://www.microsoft.com/technet/scr...ps/ps/acl.mspx
>> has everything I need besides the last modified date of the file.
>>
>> PS C:\> get-childitem c:\work –recurse | get-acl | select-object
>> path,owner,accesstostring,group | export-csv c:\ACL.csv
>>
>> Any idea what parameter or switch I add to also list the modified
>> date as part of the CSV output? I have been trying to find resources
>> to explain the syntax better. Please send me a complete command that
>> works.
>>
>> Thanks
>>
>> Ron
>>

My System SpecsSystem Spec
Old 05-27-2008   #4 (permalink)
Ron


 
 

Re: Need help with pulling dates, ACL permissions into a CSV file

Shay -

Thanks!! The command lines you provided appears to pull the information I
need for smaller directories!

I used the lines below:
$lwt = @{n="LastWriteTime";e={ (dir(Resolve-Path
$_.PSPath).ProviderPath).lastWriteTime}}

get-childitem c:\rtools -recurse | get-acl |select-object
path,owner,accesstostring,$lwt,group | export-csv c:\testfull1.csv

But when I tried some larger directories like the full C:\ or C:\winxp I got
the error below:

Get-Acl : Attempted to perform an unauthorized operation.
At line:1 char:42
+ get-childitem c:\winxp -recurse | get-acl <<<< |select-object
path,owner,acc
esstostring,$lwt,group | export-csv c:\windowstest.csv

So I am not sure if certain files, temp files or size limits are in place.
For example the full root of C:\ produced output of over 64,000 records or
C:\winxp about 11,000 records (despite error output file was created). In
addition I noticed the CPU usage was between 70-100%.

Therefore you have tips on :
1) Resolving or understanding the error :Get-Acl : Attempted to perform an
unauthorized operation." If this cannot be resolved is output file created
represent all permissions of file that were scanned successfully or only
files ACL's scanned up until the point of the error?

2) A method to control the CPU usage of powershell in some way, so servers
are not overwhelmed. I was already thinking we will need to run this off
hours, but is there more that can be done to control CPU usage?


Thank you for such a speedy response.


"Shay Levi" wrote:
Quote:

>
> You can skip the path translation and let PowerShell resolve it:
>
> $lwt = @{n="LastWriteTime";e={ (dir $_.PSPath).lastWriteTime }}
>
>
> ---
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
>
Quote:

> > Hi
> >
> > If you'll pipe this to get-member you'll see a property called pspath,
> > its how Windows PowerShell see the file path :
> >
> > get-childitem c:\work | gm
> >
> > You can translate this pspath to a file system path by using the
> > Resolve-Path cmdlet, then use get-childitem (dir) to get the
> > lastWriteTime property of each file and append it as a new coulmn
> > (property) using a calculated property:
> >
> > $lwt = @{n="LastWriteTime";e={ (dir (Resolve-Path
> > $_.PSPath).ProviderPath).lastWriteTime
> > }}
> > get-childitem c:\work –recurse | get-acl | select-object
> > path,owner,accesstostring,group,$lwt
> > | export-csv c:\ACL.csv
> > More on Calculated Properties:
> > http://www.microsoft.com/technet/scr...pstips/apr08/p
> > stip0425.mspx
> > ---
> > Shay Levi
> > $cript Fanatic
> > http://scriptolog.blogspot.com
Quote:

> >> All -
> >>
> >> I am trying to use Powershell to get ACL's for me on files residing
> >> on various servers. I need the command to run recursively from the
> >> root path specified and get active acl permissions,
> >> fullpath/filename, modified date, owner, and group membership. This
> >> way I should be able to get a CSV file for files in directories ( and
> >> sub directories I specify.
> >>
> >> I found a command (see link or below) in powershell on "Scripting Guy
> >> forums" on
> >> http://www.microsoft.com/technet/scr...ps/ps/acl.mspx
> >> has everything I need besides the last modified date of the file.
> >>
> >> PS C:\> get-childitem c:\work –recurse | get-acl | select-object
> >> path,owner,accesstostring,group | export-csv c:\ACL.csv
> >>
> >> Any idea what parameter or switch I add to also list the modified
> >> date as part of the CSV output? I have been trying to find resources
> >> to explain the syntax better. Please send me a complete command that
> >> works.
> >>
> >> Thanks
> >>
> >> Ron
> >>
>
>
>
My System SpecsSystem Spec
Old 05-27-2008   #5 (permalink)
Ron


 
 

Re: Need help with pulling dates, ACL permissions into a CSV file

I am running the scans on my local machine , the same pc that has powershell
so everything is local. I added my domain account as a member of the local
Administrator group. I rebooted and below is what I ran into, let me know
what you think.

PS C:\WINXP\system32\windowspowershell\v1.0> get-childitem c:\winxp -recurse
| g
et-acl |select-object path,owner,accesstostring,$lwt,group | export-csv
c:\windo
wstest.csv
Get-Acl : Attempted to perform an unauthorized operation.
At line:1 char:42
+ get-childitem c:\winxp -recurse | get-acl <<<< |select-object
path,owner,acc
esstostring,$lwt,group | export-csv c:\windowstest.csv
PS C:\WINXP\system32\windowspowershell\v1.0> $error[0] | fl -force


Exception : System.UnauthorizedAccessException: Attempted to
perfor
m an unauthorized operation.
at
System.Security.AccessControl.Win32.GetSecurityIn
fo(ResourceType resourceType, String name,
SafeHandle h
andle, AccessControlSections accessControlSections,
Raw
SecurityDescriptor& resultSd)
at
System.Security.AccessControl.NativeObjectSecurit
y.CreateInternal(ResourceType resourceType, Boolean
isC
ontainer, String name, SafeHandle handle,
AccessControl
Sections includeSections, Boolean createByName,
Excepti
onFromErrorCode exceptionFromErrorCode, Object
exceptio
nContext)
at
System.Security.AccessControl.FileSystemSecurity.
.ctor(Boolean isContainer, String name,
AccessControlSe
ctions includeSections, Boolean isDirectory)
at
System.Security.AccessControl.DirectorySecurity..
ctor(String name, AccessControlSections
includeSections
)
at
Microsoft.PowerShell.Commands.FileSystemProvider.
GetSecurityDescriptor(String path,
AccessControlSection
s sections)
at
System.Management.Automation.Provider.CmdletProvi
der.GetSecurityDescriptor(String path,
AccessControlSec
tions sections, CmdletProviderContext context)
at
System.Management.Automation.SessionStateInternal
.GetSecurityDescriptor(CmdletProvider
providerInstance,
String path, AccessControlSections sections,
CmdletPro
viderContext context)
TargetObject :
CategoryInfo : NotSpecified: ( [Get-Acl],
UnauthorizedAccessExceptio
n
FullyQualifiedErrorId :
System.UnauthorizedAccessException,Microsoft.PowerShell
.Commands.GetAclCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo


"Shay Levi" wrote:
Quote:

>
> Seems like a permission issue. Does the user that runs the script has the
> appropriate permissions?
> I ran the code on Vista SP1 (as administrator) on the C:\ drive and I didn't
> get any errors.
>
> Searching through the file system recursively is an intensive task. Running
> the below
> in DOS gives me 65% CPU load and thats without checking for file ACLs:
>
> dir c:\ /s
>
>
> Can you output the content of '$error[0] | fl -force' when the error occurs?
> It can shed some light.
>
>
> ---
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
>
Quote:

> > Shay -
> >
> > Thanks!! The command lines you provided appears to pull the
> > information I need for smaller directories!
> >
> > I used the lines below:
> > $lwt = @{n="LastWriteTime";e={ (dir(Resolve-Path
> > $_.PSPath).ProviderPath).lastWriteTime}}
> > get-childitem c:\rtools -recurse | get-acl |select-object
> > path,owner,accesstostring,$lwt,group | export-csv c:\testfull1.csv
> >
> > But when I tried some larger directories like the full C:\ or C:\winxp
> > I got the error below:
> >
> > Get-Acl : Attempted to perform an unauthorized operation.
> > At line:1 char:42
> > + get-childitem c:\winxp -recurse | get-acl <<<< |select-object
> > path,owner,acc
> > esstostring,$lwt,group | export-csv c:\windowstest.csv
> > So I am not sure if certain files, temp files or size limits are in
> > place. For example the full root of C:\ produced output of over 64,000
> > records or C:\winxp about 11,000 records (despite error output file
> > was created). In addition I noticed the CPU usage was between 70-100%.
> >
> > Therefore you have tips on :
> > 1) Resolving or understanding the error :Get-Acl : Attempted to
> > perform an
> > unauthorized operation." If this cannot be resolved is output file
> > created
> > represent all permissions of file that were scanned successfully or
> > only
> > files ACL's scanned up until the point of the error?
> > 2) A method to control the CPU usage of powershell in some way, so
> > servers are not overwhelmed. I was already thinking we will need to
> > run this off hours, but is there more that can be done to control CPU
> > usage?
> >
> > Thank you for such a speedy response.
> >
> > "Shay Levi" wrote:
> >
Quote:

> >> You can skip the path translation and let PowerShell resolve it:
> >>
> >> $lwt = @{n="LastWriteTime";e={ (dir $_.PSPath).lastWriteTime }}
> >>
> >> ---
> >> Shay Levi
> >> $cript Fanatic
> >> http://scriptolog.blogspot.com
> >>> Hi
> >>>
> >>> If you'll pipe this to get-member you'll see a property called
> >>> pspath, its how Windows PowerShell see the file path :
> >>>
> >>> get-childitem c:\work | gm
> >>>
> >>> You can translate this pspath to a file system path by using the
> >>> Resolve-Path cmdlet, then use get-childitem (dir) to get the
> >>> lastWriteTime property of each file and append it as a new coulmn
> >>> (property) using a calculated property:
> >>>
> >>> $lwt = @{n="LastWriteTime";e={ (dir (Resolve-Path
> >>> $_.PSPath).ProviderPath).lastWriteTime
> >>> }}
> >>> get-childitem c:\work –recurse | get-acl | select-object
> >>> path,owner,accesstostring,group,$lwt
> >>> | export-csv c:\ACL.csv
> >>> More on Calculated Properties:
> >>> http://www.microsoft.com/technet/scr...s/pstips/apr08
> >>> /p
> >>> stip0425.mspx
> >>> ---
> >>> Shay Levi
> >>> $cript Fanatic
> >>> http://scriptolog.blogspot.com
> >>>> All -
> >>>>
> >>>> I am trying to use Powershell to get ACL's for me on files residing
> >>>> on various servers. I need the command to run recursively from the
> >>>> root path specified and get active acl permissions,
> >>>> fullpath/filename, modified date, owner, and group membership. This
> >>>> way I should be able to get a CSV file for files in directories (
> >>>> and sub directories I specify.
> >>>>
> >>>> I found a command (see link or below) in powershell on "Scripting
> >>>> Guy forums" on
> >>>> http://www.microsoft.com/technet/scr...ps/ps/acl.mspx
> >>>> has everything I need besides the last modified date of the file.
> >>>>
> >>>> PS C:\> get-childitem c:\work –recurse | get-acl | select-object
> >>>> path,owner,accesstostring,group | export-csv c:\ACL.csv
> >>>>
> >>>> Any idea what parameter or switch I add to also list the modified
> >>>> date as part of the CSV output? I have been trying to find
> >>>> resources to explain the syntax better. Please send me a complete
> >>>> command that works.
> >>>>
> >>>> Thanks
> >>>>
> >>>> Ron
> >>>>
>
>
>
My System SpecsSystem Spec
Old 05-27-2008   #6 (permalink)
Shay Levi


 
 

Re: Need help with pulling dates, ACL permissions into a CSV file


Seems like a permission issue. Does the user that runs the script has the
appropriate permissions?
I ran the code on Vista SP1 (as administrator) on the C:\ drive and I didn't
get any errors.

Searching through the file system recursively is an intensive task. Running
the below
in DOS gives me 65% CPU load and thats without checking for file ACLs:

dir c:\ /s


Can you output the content of '$error[0] | fl -force' when the error occurs?
It can shed some light.


---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> Shay -
>
> Thanks!! The command lines you provided appears to pull the
> information I need for smaller directories!
>
> I used the lines below:
> $lwt = @{n="LastWriteTime";e={ (dir(Resolve-Path
> $_.PSPath).ProviderPath).lastWriteTime}}
> get-childitem c:\rtools -recurse | get-acl |select-object
> path,owner,accesstostring,$lwt,group | export-csv c:\testfull1.csv
>
> But when I tried some larger directories like the full C:\ or C:\winxp
> I got the error below:
>
> Get-Acl : Attempted to perform an unauthorized operation.
> At line:1 char:42
> + get-childitem c:\winxp -recurse | get-acl <<<< |select-object
> path,owner,acc
> esstostring,$lwt,group | export-csv c:\windowstest.csv
> So I am not sure if certain files, temp files or size limits are in
> place. For example the full root of C:\ produced output of over 64,000
> records or C:\winxp about 11,000 records (despite error output file
> was created). In addition I noticed the CPU usage was between 70-100%.
>
> Therefore you have tips on :
> 1) Resolving or understanding the error :Get-Acl : Attempted to
> perform an
> unauthorized operation." If this cannot be resolved is output file
> created
> represent all permissions of file that were scanned successfully or
> only
> files ACL's scanned up until the point of the error?
> 2) A method to control the CPU usage of powershell in some way, so
> servers are not overwhelmed. I was already thinking we will need to
> run this off hours, but is there more that can be done to control CPU
> usage?
>
> Thank you for such a speedy response.
>
> "Shay Levi" wrote:
>
Quote:

>> You can skip the path translation and let PowerShell resolve it:
>>
>> $lwt = @{n="LastWriteTime";e={ (dir $_.PSPath).lastWriteTime }}
>>
>> ---
>> Shay Levi
>> $cript Fanatic
>> http://scriptolog.blogspot.com
Quote:

>>> Hi
>>>
>>> If you'll pipe this to get-member you'll see a property called
>>> pspath, its how Windows PowerShell see the file path :
>>>
>>> get-childitem c:\work | gm
>>>
>>> You can translate this pspath to a file system path by using the
>>> Resolve-Path cmdlet, then use get-childitem (dir) to get the
>>> lastWriteTime property of each file and append it as a new coulmn
>>> (property) using a calculated property:
>>>
>>> $lwt = @{n="LastWriteTime";e={ (dir (Resolve-Path
>>> $_.PSPath).ProviderPath).lastWriteTime
>>> }}
>>> get-childitem c:\work –recurse | get-acl | select-object
>>> path,owner,accesstostring,group,$lwt
>>> | export-csv c:\ACL.csv
>>> More on Calculated Properties:
>>> http://www.microsoft.com/technet/scr...s/pstips/apr08
>>> /p
>>> stip0425.mspx
>>> ---
>>> Shay Levi
>>> $cript Fanatic
>>> http://scriptolog.blogspot.com
>>>> All -
>>>>
>>>> I am trying to use Powershell to get ACL's for me on files residing
>>>> on various servers. I need the command to run recursively from the
>>>> root path specified and get active acl permissions,
>>>> fullpath/filename, modified date, owner, and group membership. This
>>>> way I should be able to get a CSV file for files in directories (
>>>> and sub directories I specify.
>>>>
>>>> I found a command (see link or below) in powershell on "Scripting
>>>> Guy forums" on
>>>> http://www.microsoft.com/technet/scr...ps/ps/acl.mspx
>>>> has everything I need besides the last modified date of the file.
>>>>
>>>> PS C:\> get-childitem c:\work –recurse | get-acl | select-object
>>>> path,owner,accesstostring,group | export-csv c:\ACL.csv
>>>>
>>>> Any idea what parameter or switch I add to also list the modified
>>>> date as part of the CSV output? I have been trying to find
>>>> resources to explain the syntax better. Please send me a complete
>>>> command that works.
>>>>
>>>> Thanks
>>>>
>>>> Ron
>>>>

My System SpecsSystem Spec
Old 05-29-2008   #7 (permalink)
Ron


 
 

Re: Need help with pulling dates, ACL permissions into a CSV file

Shay or others any ideas what the issue may be, based of my error output below?

thanks

"Ron" wrote:
Quote:

> I am running the scans on my local machine , the same pc that has powershell
> so everything is local. I added my domain account as a member of the local
> Administrator group. I rebooted and below is what I ran into, let me know
> what you think.
>
> PS C:\WINXP\system32\windowspowershell\v1.0> get-childitem c:\winxp -recurse
> | g
> et-acl |select-object path,owner,accesstostring,$lwt,group | export-csv
> c:\windo
> wstest.csv
> Get-Acl : Attempted to perform an unauthorized operation.
> At line:1 char:42
> + get-childitem c:\winxp -recurse | get-acl <<<< |select-object
> path,owner,acc
> esstostring,$lwt,group | export-csv c:\windowstest.csv
> PS C:\WINXP\system32\windowspowershell\v1.0> $error[0] | fl -force
>
>
> Exception : System.UnauthorizedAccessException: Attempted to
> perfor
> m an unauthorized operation.
> at
> System.Security.AccessControl.Win32.GetSecurityIn
> fo(ResourceType resourceType, String name,
> SafeHandle h
> andle, AccessControlSections accessControlSections,
> Raw
> SecurityDescriptor& resultSd)
> at
> System.Security.AccessControl.NativeObjectSecurit
> y.CreateInternal(ResourceType resourceType, Boolean
> isC
> ontainer, String name, SafeHandle handle,
> AccessControl
> Sections includeSections, Boolean createByName,
> Excepti
> onFromErrorCode exceptionFromErrorCode, Object
> exceptio
> nContext)
> at
> System.Security.AccessControl.FileSystemSecurity.
> .ctor(Boolean isContainer, String name,
> AccessControlSe
> ctions includeSections, Boolean isDirectory)
> at
> System.Security.AccessControl.DirectorySecurity..
> ctor(String name, AccessControlSections
> includeSections
> )
> at
> Microsoft.PowerShell.Commands.FileSystemProvider.
> GetSecurityDescriptor(String path,
> AccessControlSection
> s sections)
> at
> System.Management.Automation.Provider.CmdletProvi
> der.GetSecurityDescriptor(String path,
> AccessControlSec
> tions sections, CmdletProviderContext context)
> at
> System.Management.Automation.SessionStateInternal
> .GetSecurityDescriptor(CmdletProvider
> providerInstance,
> String path, AccessControlSections sections,
> CmdletPro
> viderContext context)
> TargetObject :
> CategoryInfo : NotSpecified: ( [Get-Acl],
> UnauthorizedAccessExceptio
> n
> FullyQualifiedErrorId :
> System.UnauthorizedAccessException,Microsoft.PowerShell
> .Commands.GetAclCommand
> ErrorDetails :
> InvocationInfo : System.Management.Automation.InvocationInfo
>
>
> "Shay Levi" wrote:
>
Quote:

> >
> > Seems like a permission issue. Does the user that runs the script has the
> > appropriate permissions?
> > I ran the code on Vista SP1 (as administrator) on the C:\ drive and I didn't
> > get any errors.
> >
> > Searching through the file system recursively is an intensive task. Running
> > the below
> > in DOS gives me 65% CPU load and thats without checking for file ACLs:
> >
> > dir c:\ /s
> >
> >
> > Can you output the content of '$error[0] | fl -force' when the error occurs?
> > It can shed some light.
> >
> >
> > ---
> > Shay Levi
> > $cript Fanatic
> > http://scriptolog.blogspot.com
> >
Quote:

> > > Shay -
> > >
> > > Thanks!! The command lines you provided appears to pull the
> > > information I need for smaller directories!
> > >
> > > I used the lines below:
> > > $lwt = @{n="LastWriteTime";e={ (dir(Resolve-Path
> > > $_.PSPath).ProviderPath).lastWriteTime}}
> > > get-childitem c:\rtools -recurse | get-acl |select-object
> > > path,owner,accesstostring,$lwt,group | export-csv c:\testfull1.csv
> > >
> > > But when I tried some larger directories like the full C:\ or C:\winxp
> > > I got the error below:
> > >
> > > Get-Acl : Attempted to perform an unauthorized operation.
> > > At line:1 char:42
> > > + get-childitem c:\winxp -recurse | get-acl <<<< |select-object
> > > path,owner,acc
> > > esstostring,$lwt,group | export-csv c:\windowstest.csv
> > > So I am not sure if certain files, temp files or size limits are in
> > > place. For example the full root of C:\ produced output of over 64,000
> > > records or C:\winxp about 11,000 records (despite error output file
> > > was created). In addition I noticed the CPU usage was between 70-100%.
> > >
> > > Therefore you have tips on :
> > > 1) Resolving or understanding the error :Get-Acl : Attempted to
> > > perform an
> > > unauthorized operation." If this cannot be resolved is output file
> > > created
> > > represent all permissions of file that were scanned successfully or
> > > only
> > > files ACL's scanned up until the point of the error?
> > > 2) A method to control the CPU usage of powershell in some way, so
> > > servers are not overwhelmed. I was already thinking we will need to
> > > run this off hours, but is there more that can be done to control CPU
> > > usage?
> > >
> > > Thank you for such a speedy response.
> > >
> > > "Shay Levi" wrote:
> > >
> > >> You can skip the path translation and let PowerShell resolve it:
> > >>
> > >> $lwt = @{n="LastWriteTime";e={ (dir $_.PSPath).lastWriteTime }}
> > >>
> > >> ---
> > >> Shay Levi
> > >> $cript Fanatic
> > >> http://scriptolog.blogspot.com
> > >>> Hi
> > >>>
> > >>> If you'll pipe this to get-member you'll see a property called
> > >>> pspath, its how Windows PowerShell see the file path :
> > >>>
> > >>> get-childitem c:\work | gm
> > >>>
> > >>> You can translate this pspath to a file system path by using the
> > >>> Resolve-Path cmdlet, then use get-childitem (dir) to get the
> > >>> lastWriteTime property of each file and append it as a new coulmn
> > >>> (property) using a calculated property:
> > >>>
> > >>> $lwt = @{n="LastWriteTime";e={ (dir (Resolve-Path
> > >>> $_.PSPath).ProviderPath).lastWriteTime
> > >>> }}
> > >>> get-childitem c:\work –recurse | get-acl | select-object
> > >>> path,owner,accesstostring,group,$lwt
> > >>> | export-csv c:\ACL.csv
> > >>> More on Calculated Properties:
> > >>> http://www.microsoft.com/technet/scr...s/pstips/apr08
> > >>> /p
> > >>> stip0425.mspx
> > >>> ---
> > >>> Shay Levi
> > >>> $cript Fanatic
> > >>> http://scriptolog.blogspot.com
> > >>>> All -
> > >>>>
> > >>>> I am trying to use Powershell to get ACL's for me on files residing
> > >>>> on various servers. I need the command to run recursively from the
> > >>>> root path specified and get active acl permissions,
> > >>>> fullpath/filename, modified date, owner, and group membership. This
> > >>>> way I should be able to get a CSV file for files in directories (
> > >>>> and sub directories I specify.
> > >>>>
> > >>>> I found a command (see link or below) in powershell on "Scripting
> > >>>> Guy forums" on
> > >>>> http://www.microsoft.com/technet/scr...ps/ps/acl.mspx
> > >>>> has everything I need besides the last modified date of the file.
> > >>>>
> > >>>> PS C:\> get-childitem c:\work –recurse | get-acl | select-object
> > >>>> path,owner,accesstostring,group | export-csv c:\ACL.csv
> > >>>>
> > >>>> Any idea what parameter or switch I add to also list the modified
> > >>>> date as part of the CSV output? I have been trying to find
> > >>>> resources to explain the syntax better. Please send me a complete
> > >>>> command that works.
> > >>>>
> > >>>> Thanks
> > >>>>
> > >>>> Ron
> > >>>>
> >
> >
> >
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Last Modified file dates Vista General
Change EXIF and File dates PowerShell
File Modification Dates in IExpress package VB Script
file dates Vista performance & maintenance
File Open window lacks file dates Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46