View Single Post
Old 09-04-2008   #4 (permalink)
TimParker


 
 

Re: Log In Out File Processing

David --

Thanks for the code. I will give that a shot. We took a bit of a
different approach and threw the data into a couple hashtables and
have it almost working well. But I am now to almost the end of the
"current" requirements for this.

I have a hash table that returns If I type the folliowing:

PSH> $users[$key]

Name
Value
----
-----
WKSTN0033 Login

so If then type the following I would expect to get true back but it
returns false.

$users[$key].ContainsValue("Login")

Any ideas why? There are no spaces around the text. We did have some
spaces in the beginning due to the way that I wrote the original batch
file, but I cleaned all that up.

TIA.

Tim



On Sep 3, 2:24*pm, David Moravec <David
Mora...@xxxxxx> wrote:
Quote:

> Hi,
> You can use something similar to this:
>
> $file = Get-Content ./log.csv
>
> $h = @{}
> $htmlFile = "output.html"
> $htmlBegin = "<html><head></head><body><table>"
> $htmlMid = ""
> $htmlEnd = "</table><br>By PowerShell </body>"
>
> foreach ($line in $file) {
> * * * * $hk = $line.split(";")[1]
> * * * * $hv = $line.split(";")[4]
> * * * * $h[$hk] = $hv
>
> }
>
> $h.get_Keys() |% {
> * * * * $htmlMid = $htmlMid + "<tr>"
> * * * * if ($h.Get_Item($_) -eq "Login") {
> * * * * * * * * $htmlMid = $htmlMid + "<td bgcolor=`"green`">$_</td>"
> * * * * * * * * $htmlMid = $htmlMid + "<td bgcolor=`"green`">" + $h.Get_Item($_) + "</td>"
> * * * * }
> * * * * else {
> * * * * * * * * $htmlMid = $htmlMid + "<td bgcolor=`"red`">$_</td>"
> * * * * * * * * $htmlMid = $htmlMid + "<td bgcolor=`"red`">" + $h.Get_Item($_) + "</td>"
> * * * * }
> * * * * $htmlMid = $htmlMid + "</tr>"
>
> }
>
> Set-Content $htmlBegin$htmlMid$htmlEnd -Path $htmlFile
>
> Enjoy it,
> David
>
>
>
> "TimParker" wrote:
Quote:

> > Sorry, hit the wrong key.....
>
Quote:

> > *I have a new project that I am working on, my boss decided to morph a
> > *previous project and add something new to it now. I have a file that
> > I
> > *have is created through login and logout scripts. The following is
> > the
> > *layout for the CSV file.
>
Quote:

> > *machine1 * * * * user1 * * * *09/03/2008 * * *10:15:27.20 * * Login
> > *machine2 * * * * user2 * * * 09/03/2008 * * *10:28:44.87 * * Login
> > *machine3 * * * * user3 * * * 09/03/2008 * * *10:32:51.23 * * LogOut
>
Quote:

> > I need to be able to loop through this data and create a web page that
> > say changes the color of their name to either red or green for in the
> > office or out. I am pulling the data from the file based on the
> > current date. So I can have multiple logins and multiple machines even
> > per user. My boss is thinking that I need to look at matches, same
> > machine, user and ignore those and then that will leave potentially a
> > login (still in the office).
>
Quote:

> > Thoughts on the best way to sort through this and come up with the end
> > result.
>
Quote:

> > TIA.
>
Quote:

> > Tim- Hide quoted text -
>
> - Show quoted text -
My System SpecsSystem Spec