Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Powershell use Get-ChildItem

Posted on 2009-12-30
3
Medium Priority
?
824 Views
Last Modified: 2013-12-07
I need to clean data out of my IIs logs before webtrends processes them.  How can I pass the Get-ChildItem -Name results into an array and then run the following command against each item in the array?

(Type $ChildItemVariable1.log) -Notwith "192.168.11.24" | Out-File $ChildItemVariable1.log
0
Comment
Question by:ThatVaiGuy
  • 2
3 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 total points
ID: 26149627

Hmmm... -NotWith?

Perhaps...

$Dir = "C:\Whatever"
ForEach ($File in (Get-ChildItem $Dir)
{
  (Type $File.Name) -NotWith "192.168.11.24" | Out-File $File.Name
}

Not entirely clear what you're doing to the file, so that simply encapsulates the command in a very simple loop.

Chris
0
 
LVL 1

Author Comment

by:ThatVaiGuy
ID: 26153192
Sorry, that should have read "-notmatch".  I kept thinking it was -notwith yesterday, but that parameter is not valid.  Forgive me, It was an error on my part.
0
 
LVL 1

Author Closing Comment

by:ThatVaiGuy
ID: 31671359
Chris-Dent is right that the parameter -notwith is incorrect.  the correct parameter to use is -notmatch.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Welcome to 2018! Exciting things lie ahead in the world of tech. To start things off, we compiled great member articles on how to stay safe, ways to learn, and much more! Read on to start your new year right.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

571 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