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 - Help a newbie

Reply
 
Old 05-16-2007   #1 (permalink)
brhessel


 
 

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 SpecsSystem Spec
Old 05-16-2007   #2 (permalink)
Jeffery Hicks


 
 

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 SpecsSystem Spec
Old 05-16-2007   #3 (permalink)
brhessel


 
 

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 SpecsSystem Spec
Old 05-16-2007   #4 (permalink)
brhessel


 
 

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 SpecsSystem Spec
Old 05-16-2007   #5 (permalink)
Keith Hill [MVP]


 
 

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 SpecsSystem Spec
Old 05-23-2007   #6 (permalink)
brhessel


 
 

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 SpecsSystem Spec
Old 05-23-2007   #7 (permalink)
Keith Hill


 
 

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 SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Newbie help Gaming
Re: WLM newbie Live Mail
Newbie PowerShell
newbie VB Script
Newbie needs help General Discussion


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