cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 

Powershell and command

tolinrome
Level 4

My goal is to run a script in Powershell that will return the jobtype of backup of the datasize, and I only want the results for th elast 1 day.

If I run this command below I get the results from everday in the job history including alot of unwanted extra data.

$session = New-PSSession -computerName "Server1"

Invoke-Command -Session $session {Import-Module BEMCLI}

Invoke-Command -Session $session {Get-BEJobHistory -jobtype backup}

If I run this command, it "seems" to run successfully since it takes time then just finishes and I'm back at the command prompt and it also creates the CSV fiel but there is no data in it. What could be the problem? Thanks!

 

$session = New-PSSession -computerName "Server1"

Invoke-Command -Session $session {Import-Module BEMCLI}

Invoke-Command -Session $session {Get-BEJobHistory -jobtype backup} | where-object {($_.startime -gt (get-date).adddays(-1))} | Export-Csv C:\scripts\reports.csv -NoTypeInformation

 

1 ACCEPTED SOLUTION

Accepted Solutions

pkh
Moderator
Moderator
   VIP    Certified

You got to use the select-object cmdlet to select the object that you want.  See this

http://technet.microsoft.com/en-us/library/ff730948.aspx

Note the part about getting kilobytes.  You can do the same thing, but use 1GB, instead of 1KB, to get your gigabytes.

View solution in original post

3 REPLIES 3

pkh
Moderator
Moderator
   VIP    Certified

1) Have you tried running these commands on the media server itself and see whether there is any result?

2) Without exporting to the CSV file, do you get any results?

*EDIT*

3) you might need to include the full path when you are importing the BEMCLI module.

import-module "\program files\symantec\backup exec\modules\bemcli\bemcli"

*END EDIT*

tolinrome
Level 4
I go tit to work in the excel spreadsheet and the script below works fine - but it returns to me all the extra details of the backup job that just ran within the last day. But what I need now is to only see the "Totaldatasizebytes", not all the other objects, and I need the "Totaldatasizebytes" changed into GB. Thanks.

$session = New-PSSession -computerName "Server1"
Invoke-Command -Session $session {
Import-Module BEMCLI
Get-BEJobHistory -jobtype backup |
where-object { $_.starttime -gt (get-date).adddays(-1) }
} | Export-Csv C:\scripts\reports.csv -NoTypeInformation

 

pkh
Moderator
Moderator
   VIP    Certified

You got to use the select-object cmdlet to select the object that you want.  See this

http://technet.microsoft.com/en-us/library/ff730948.aspx

Note the part about getting kilobytes.  You can do the same thing, but use 1GB, instead of 1KB, to get your gigabytes.