Avatar of Kelly Garcia
Kelly Garcia
Flag 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.
PowershellScripting Languages

Avatar of undefined
Last Comment
Joe Klimis

8/22/2022 - Mon
Joe Klimis

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

Joe Klimis

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

ASKER
apologies I will do this today, I was running it last week but it was taking ages
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Kelly Garcia

ASKER
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

Joe Klimis

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
Joe Klimis

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Kelly Garcia

ASKER
how do I get the job name?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Kelly Garcia

ASKER
were almost there, thank you for the help
Joe Klimis

Hi  try adding  this line at line 10

jobName = $jobinfo.name;

Open in new window