Link to home
Create AccountLog in
Avatar of Kelly Garcia
Kelly GarciaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Powershell script for BackupExec

Hi All,

I have written the script below

Get-BEMedia | ? {$_.LastModifiedDate -ge (Get-Date).AddHours(-24)} | select name, mediaset, mediasetid, lastmodifieddate, LocationName

Open in new window


I know need this information as well as information about name of the job and completion time as well if the media is currerently being used.

so my idea now is to store the mediasetid in a variable, then loop through it and get more information via get-bejob.

I need help how to writethis and get more information. so far idea is:

$mediasetid = Get-BEMedia | ? {$_.LastModifiedDate -ge (Get-Date).AddHours(-24)} | select MediaSetId


$mediasetid |  % { get-bejob | ? {$_.mediasetid -eq $mediaset}} but how do I also out the information I obtained previously, "select name, mediaset, mediasetid, lastmodifieddate, LocationName"

thank you in advance.
Avatar of Joe Klimis
Joe Klimis
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi Kay

I do not have backup exec in my environment but the following should help you . At line 14 you can add as many of the fields from the job information in , I have added the only one i know about ($jobinfo.mediasetid)

Please let me know how you get on.
Joe

$mediainfo = Get-BEMedia | ? {$_.LastModifiedDate -ge (Get-Date).AddHours(-24)} | select name, mediaset, mediasetid, lastmodifieddate, LocationName

$result=@()

foreach ($id in $mediainfo)
{

$jobinfo = get-bejob | ? {$_.mediasetid -eq $id.mediasetid}
$result += [pscustomobject] @{ 
name = $mediainfo.name; 
mediaset = $mediainfo.mediaset; 
lastmodifieddate = $mediainfo.lastmodifieddate;
LocationName = $mediainfo.LocationName;
jobinfoID = $jobinfo.mediasetid
} 


} # end foreach

$result | ft

Open in new window

Hi Kay
have you tried this yet ?  how did you get on
Joe
Avatar of Kelly Garcia

ASKER

apologies I will do this today, I was running it last week but it was taking ages
this don't give me any values, this is resuts:

Name                           Value
----                           -----
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName
jobinfoID
name
mediaset
lastmodifieddate
LocationName

Open in new window

Can you verify what version of powershell you are running , you can find this by typing
$host.version 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Joe Klimis
Joe Klimis
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
how do I get the job name?
were almost there, thank you for the help
Hi  try adding  this line at line 10

jobName = $jobinfo.name;

Open in new window