![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Help a newbie I'm trying to learn Powershell (reading Powershell in Action right now) but I am struggling with some of the basics and running out of time for a script I need. I want to find all files with a certain extension on a share and output the results in a nice format that contains the path, name, size in MB, and last access time. So far I have: get-ChildItem -recurse -include a_*.nsf | Out-File -FilePath c: \archives.txt but this doesn't give me all the information I am looking for nor put it in a very nice format. I'm sure if I spend some more time on this I could get it but right now I am in a rush. Thanks for any help. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Help a newbie On 16 May 2007 07:09:51 -0700, brhessel wrote: > I'm trying to learn Powershell (reading Powershell in Action right > now) but I am struggling with some of the basics and running out of > time for a script I need. > > I want to find all files with a certain extension on a share and > output the results in a nice format that contains the path, name, size > in MB, and last access time. So far I have: > > get-ChildItem -recurse -include a_*.nsf | Out-File -FilePath c: > \archives.txt > > but this doesn't give me all the information I am looking for nor put > it in a very nice format. I'm sure if I spend some more time on this I > could get it but right now I am in a rush. Thanks for any help. You are on the right track. Try something like this: PS S:\ > gci *.bat | select FullName,Length,LastAccessTime | out-file ..\batfiles.txt One thing about LastAccessTime is that it is not necessarily the last time a user accessed the file. Things like Antivirus scans and defrags can affect this property. -- Jeffery Hicks SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com VBScript & Windows PowerShell Training - www.ScriptingTraining.com/classes.asp Windows PowerShell? - www.SAPIENPress.com/powershell.asp blog: http://blog.SAPIEN.com blog: http://jdhitsolutions.blogspot.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Help a newbie On May 16, 10:53 am, Jeffery Hicks <"jhicks[at]SAPIEN.com"> wrote: > On 16 May 2007 07:09:51 -0700, brhessel wrote: > > > I'm trying to learn Powershell (reading Powershell in Action right > > now) but I am struggling with some of the basics and running out of > > time for a script I need. > > > I want to find all files with a certain extension on a share and > > output the results in a nice format that contains the path, name, size > > in MB, and last access time. So far I have: > > > get-ChildItem -recurse -include a_*.nsf | Out-File -FilePath c: > > \archives.txt > > > but this doesn't give me all the information I am looking for nor put > > it in a very nice format. I'm sure if I spend some more time on this I > > could get it but right now I am in a rush. Thanks for any help. > > You are on the right track. Try something like this: > PS S:\ > gci *.bat | select FullName,Length,LastAccessTime | out-file > .\batfiles.txt > > One thing about LastAccessTime is that it is not necessarily the last time > a user accessed the file. Things like Antivirus scans and defrags can > affect this property. > > -- > Jeffery Hicks > SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com > VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp > Windows PowerShell? -www.SAPIENPress.com/powershell.asp > > blog:http://blog.SAPIEN.com > blog:http://jdhitsolutions.blogspot.com So I am up to this: get-ChildItem -recurse -include a_*.nsf |Select-Object Name,FullName,Length,LastAccessTime |export-Csv -path C:\archives.csv how would I convert the length into MB before exporting it? |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Help a newbie On May 16, 10:53 am, Jeffery Hicks <"jhicks[at]SAPIEN.com"> wrote: > On 16 May 2007 07:09:51 -0700, brhessel wrote: > > > I'm trying to learn Powershell (reading Powershell in Action right > > now) but I am struggling with some of the basics and running out of > > time for a script I need. > > > I want to find all files with a certain extension on a share and > > output the results in a nice format that contains the path, name, size > > in MB, and last access time. So far I have: > > > get-ChildItem -recurse -include a_*.nsf | Out-File -FilePath c: > > \archives.txt > > > but this doesn't give me all the information I am looking for nor put > > it in a very nice format. I'm sure if I spend some more time on this I > > could get it but right now I am in a rush. Thanks for any help. > > You are on the right track. Try something like this: > PS S:\ > gci *.bat | select FullName,Length,LastAccessTime | out-file > .\batfiles.txt > > One thing about LastAccessTime is that it is not necessarily the last time > a user accessed the file. Things like Antivirus scans and defrags can > affect this property. > > -- > Jeffery Hicks > SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com > VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp > Windows PowerShell? -www.SAPIENPress.com/powershell.asp > > blog:http://blog.SAPIEN.com > blog:http://jdhitsolutions.blogspot.com Ok so I am up to: get-ChildItem -recurse -include a_*.nsf |Select-Object Name,FullName,Length,LastAccessTime |export-Csv -path C:\archives.csv How do I convert the Length into MB before exporting it? |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Help a newbie "brhessel" <brianhesseling@gmail.com> wrote in message news:1179343841.544924.165940@k79g2000hse.googlegroups.com... > > Ok so I am up to: > > get-ChildItem -recurse -include a_*.nsf |Select-Object > Name,FullName,Length,LastAccessTime |export-Csv -path C:\archives.csv > > How do I convert the Length into MB before exporting it? get-ChildItem -recurse -include a_*.nsf |Select-Object Name,FullName,@{n='Length';e={$_.Length/1MB}},LastAccessTime |export-Csv -path C:\archives.csv Note that Select-Object and a number of other cmdlets allow you to use a hashtable to specify the name and value for a computed property. -- Keith |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Help a newbie On May 16, 3:37 pm, "Keith Hill [MVP]" <r_keith_h...@no.spam.thank.u.hotmail.com> wrote: > "brhessel" <brianhessel...@gmail.com> wrote in message > > news:1179343841.544924.165940@k79g2000hse.googlegroups.com... > > > > > Ok so I am up to: > > > get-ChildItem -recurse -include a_*.nsf |Select-Object > > Name,FullName,Length,LastAccessTime |export-Csv -path C:\archives.csv > > > How do I convert the Length into MB before exporting it? > > get-ChildItem -recurse -include a_*.nsf |Select-Object > Name,FullName,@{n='Length';e={$_.Length/1MB}},LastAccessTime > |export-Csv -path C:\archives.csv > > Note that Select-Object and a number of other cmdlets allow you to use a > hashtable to specify the name and value for a computed property. > > -- > Keith Thanks Keith. I now have approval to move these files from there old location to a temporary one before deleting them. Since I have the results in a CSV file would it be easier to retrieve the path from there and use it to move them or should I modify my find script to move what it finds? I would think it would be easier to use the find script but quicker to use the CSV since it won't have to search for the files again. Thoughts? any examples would be great help also. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Help a newbie "brhessel" <brianhesseling@gmail.com> wrote in message news:1179927825.399104.78190@g4g2000hsf.googlegroups.com... > On May 16, 3:37 pm, "Keith Hill [MVP]" > Thanks Keith. I now have approval to move these files from there old > location to a temporary one before deleting them. Since I have the > results in a CSV file would it be easier to retrieve the path from > there and use it to move them or should I modify my find script to > move what it finds? I would think it would be easier to use the find > script but quicker to use the CSV since it won't have to search for > the files again. Thoughts? any examples would be great help also. > Well the CSV file has the benefit of documenting what has been removed. If you use the CSV file then you might want to mark the files that were moved successfully so that if you have to restart the operation, you can skip those files. -- Keith |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Newbie help | Gaming | |||
| Re: WLM newbie | Live Mail | |||
| Newbie | PowerShell | |||
| newbie | VB Script | |||
| Newbie needs help | General Discussion | |||