Forum Discussion

tolinrome's avatar
tolinrome
Level 4
11 years ago

Powershell and command

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

 

3 Replies

  • 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*

  • 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