Jump to content

I am teaching myself to learn powershell, and gave myself a challege.  I am trying to make a script that does the following.  It needs to find all files with the following extensions:  .txt, .doc, .docx, and .ppt on my system that have not been modified in the last 90 days.  The output of the script should then be sent to a text file with the name of file, length of file and the last update date.  If someone could help me write this script, I would greatly appreciate it.  

Link to comment
https://linustechtips.com/topic/475531-confused-powershell-beginner/
Share on other sites

Link to post
Share on other sites

I am teaching myself to learn powershell, and gave myself a challege ... If someone could help me write this script, I would greatly appreciate it.

At the risk of stating the complete obvious... it won't be much of a challenge then will it.

The single biggest problem in communication is the illusion that it has taken place.

Link to post
Share on other sites

Link to post
Share on other sites

Somthing like:

Get-ChildItem -Path c:\ -Recurse -Include *.txt | Where-Object -FilterScript {$_.LastWriteTime -ge (Get-Date).AddDays(90)} | Select-Object -Property Name,Length,LastWriteTime | Out-File -FilePath C:\dir\somthing.txt

this will have errors, I am not going to make it that easy for you.

Link to post
Share on other sites

I am teaching myself to learn powershell, and gave myself a challege.

I know, being completely honest.  This is a homework question...

So you lied.

I am not going to make it that easy for you.

@Blake and you're an idiot for helping him.

The single biggest problem in communication is the illusion that it has taken place.

Link to post
Share on other sites

I know, being completely honest.  This is a homework question and my teacher said we can use any resources to complete the problem.

 

At least be honest from the beginning. People here will still help you even though it's homework. Now there's some people who wont help you because you lied.

 

Also, show that you've put in some effort. This is another reason why someone might not help you. Explain what parts you don't understand. Show what you've done so far, even if it's not working. We want to help you learn to code and solve problems, not just give you the answer so you can copy/paste it for a grade. 

 

If you don't know where to start, break the problem down into simpler problems and work at solving them before piecing them together.

  1. How can I find all files in a directory
  2. How can I find all files in a directory with a specific extension
  3. How can I see when a file was last modified
  4. etc
Link to post
Share on other sites

@Blake and you're an idiot for helping him.

No, it's job security. No-one will hire him past helpdesk if he can't automate mundane tasks. = my skills of actually understanding a scripting language just became slightly more valuable.

 

also it will have an error if there is a file path + name longer then 256 characters, plus there is no error handling. this would fail at university/higher education. if he is still in school then he'd get a solid C (and if i was marking, id fail him for the lack of comments).

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×