header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Subject: calculate vaule from text files
Prev Next
You are not authorized to post a reply.

Author Messages
ssaehrigUser is Offline
Shell User
Shell User
Posts:29


07/18/2008 11:47 AM  

I have a back file that is written weekly. I need to retrieve the data and calculate how many terabytes are being written. this is what i have so far. the only part i cant get to work is  the division of the bytes to terabytes.i am sending this to another text so that it can be reviewed later as an archive. any ideas?

 


$date = Get-Date -UFormat "%y.%m.%d"
$res = @()
gc \\servername\d$\mediawritten\media*.txt | Select-String kilobytes | Out-File -FilePath c:\txt\tempresults.txt
$a = Get-Content C:\txt\tempresults.txt
gc c:\txt\tempresults.txt |%{$_.split(':')Ώ]} | measure-object -sum |? {$res += $_}
$res | select Sum |% {$_.Sum #this is where i have attempted to div# }| Out-File -FilePath \\servername\d$\MediaWritten\Total\$date.MediaWrittenSum.txt

Steven Saehrig
MCP, MCTS
halr9000User is Offline
CLI Addict
CLI Addict
Posts:245


07/18/2008 12:35 PM  
how about $_.sum / 1TB

That's if your value is in bytes. Modify appropriately if not. e.g. if in kb:

$_.sum * 1kb / 1tb

Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast (http://powerscripting.net)
Author, TechProsaic (http://halr9000.com)
ssaehrigUser is Offline
Shell User
Shell User
Posts:29


07/18/2008 1:59 PM  
$_Sum * !kb/1gb/1gb worked for me TB was not recognized. thank you for the help.

Steven Saehrig
MCP, MCTS
halr9000User is Offline
CLI Addict
CLI Addict
Posts:245


07/18/2008 3:19 PM  
Ahh, right you are. Looks like this is something that they omitted from v1 but added to v2 CTP2 (which I'm running).

Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast (http://powerscripting.net)
Author, TechProsaic (http://halr9000.com)
ssaehrigUser is Offline
Shell User
Shell User
Posts:29


07/18/2008 7:13 PM  
I have not chosen to upgrade to version two because all the plug-ins I use do not work yet. I have however setup the powershell probable for version two to play with. Thank you for the help. Now all I have to do is graph the results of all the text files for a monthly overview by week.

Steven Saehrig
MCP, MCTS
ssaehrigUser is Offline
Shell User
Shell User
Posts:29


07/21/2008 2:53 PM  

Here is the final script.Hope this helps anyone who needs it.


$date = Get-Date -UFormat "%y.%m.%d"
$res = @()
gc \\PATH\media*.txt | Select-String kilobytes | Out-File -FilePath c:\txt\tempresults.txt
$a = Get-Content C:\txt\tempresults.txt
gc c:\txt\tempresults.txt |%{$_.split(':')Ώ]} | Measure-Object -sum |? {$res += $_}
$res | select Sum |% {$_.sum *1kb/1gb/1gb } | Out-File -FilePath \\PATH\Total\$date.MediaWrittenSum.txt 

 


Steven Saehrig
MCP, MCTS
halr9000User is Offline
CLI Addict
CLI Addict
Posts:245


07/21/2008 4:17 PM  
Awesome, thanks for posting the answer. :)

Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast (http://powerscripting.net)
Author, TechProsaic (http://halr9000.com)
You are not authorized to post a reply.
Forums > Using PowerShell > General PowerShell > calculate vaule from text files



ActiveForums 3.7
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer