Search found 98 matches

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

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 better way...
by grathal
Mon Nov 21, 2016 7:53 am
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 6306

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 7:38 am
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 6306

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 2:51 pm
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 6306

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 2:43 pm
Forum: PowerShell
Topic: Checking PS code to write object array to CSV file please.
Replies: 3
Views: 2616

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

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

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 11:45 am
Forum: PowerShell
Topic: Need help improving performance please ...
Replies: 11
Views: 6306

Re: Need help improving performance please ...

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

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, firstname...
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: 9947

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: 9947

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 ...