Search found 98 matches

by grathal
Tue Nov 22, 2016 6:20 am
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 8406

Re: Need help improving performance please ...

Thanks for the tips. Would you believe what I've ended up doing is using Compare-Object to report the difference between $MasterFileData and the $ValidData subset with the -PassThru parameter. I'm piping that into Out-GridView, filtering where the sideIndicator is "<=". I'm sure there's a ...
by grathal
Mon Nov 21, 2016 6:53 am
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 8406

Re: Need help improving performance please ...

Any idea why this code doesn't filter empty $_.Lastname variables please? The result is that $MasterFileData is the same as $ValidData. $MasterFileData = Import-Csv -Path $InputFile -Delimiter ';' -Header 'Lastname', 'Firstname', 'Email', 'Phone', 'Office', 'Department' $ValidData = $MasterData | Wh...
by grathal
Mon Nov 21, 2016 6:38 am
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 8406

Re: Need help improving performance please ...

Thanks! I'll test that out. My only worry is that using the Foreach-Object is a *lot* slower compared to the Where-Object. I was hoping that there was some way to also get the objects which were filtered by the Where-Object. I'm having a second issue now which is really annoying: the second line of ...
by grathal
Fri Nov 18, 2016 1:51 pm
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 8406

Re: Need help improving performance please ...

A follow-up question please. Using Where-Object is just great performance-wise for something like the following: $ValidData = $MasterFileData | Where-Object { -not ([string]::IsNullOrWhiteSpace($_.Email)) } In the same Where-Object, is there a feasible way to also get the objects that are skipped, i...
by grathal
Fri Nov 18, 2016 1:43 pm
Forum: PowerShell
Topic: Checking PS code to write object array to CSV file please.
Replies: 3
Views: 3372

Re: Checking PS code to write object array to CSV file please.

Thank you, that looks very elegant.
by grathal
Thu Nov 17, 2016 8:16 am
Forum: PowerShell
Topic: Checking PS code to write object array to CSV file please.
Replies: 3
Views: 3372

Checking PS code to write object array to CSV file please.

Hi there, I'm using Import-Csv to read an addressbook in CSV text format, one entry per line, then I'm do some validation on each entry and write it back out as a CSV file using the following PowerShell line (I also need to remove the default double-quoting as well as the header line) : $ValidData |...
by grathal
Wed Nov 16, 2016 10:45 am
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 8406

Re: Need help improving performance please ...

Thanks - that did the trick!
by grathal
Tue Nov 15, 2016 12:58 pm
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 8406

Need help improving performance please ...

Hello, I have a CSV file containing an e-mail addressbook - one line per contact - and I need to check that each line is valid. By "valid", I mean that the email address field is (at least) not empty and that there is either a first name or last name. The fields on each line are: lastname,...
by grathal
Thu Aug 25, 2016 1:42 am
Forum: PowerShell
Topic: Any quick way to check if any row in CSV file contains a specific value?
Replies: 2
Views: 15521

Re: Any quick way to check if any row in CSV file contains a specific value?

Ok thanks I'll use that version.

Using $True does seem to work though?
by grathal
Thu Aug 25, 2016 1:27 am
Forum: PowerShell
Topic: Any quick way to check if any row in CSV file contains a specific value?
Replies: 2
Views: 15521

Any quick way to check if any row in CSV file contains a specific value?

Hi there, I have a CSV file called somefile.csv like the following: ServerName,DoSomeThing Tom,FALSE Dick,FALSE Harry,TRUE In a script, I want to load the file and then stop the script if $DoSomeThing is FALSE everywhere. Do I have to use a where loop on each line, like below, or is there something ...