We help IT Professionals succeed at work.

Powershell script for BackupExec

108 Views
Last Modified: 2018-02-06
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.
Comment
Watch Question

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
Kelly GarciaSenior Systems Administrator

Author

Commented:
apologies I will do this today, I was running it last week but it was taking ages
Kelly GarciaSenior Systems Administrator

Author

Commented:
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

This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Kelly GarciaSenior Systems Administrator

Author

Commented:
how do I get the job name?
Kelly GarciaSenior Systems Administrator

Author

Commented:
were almost there, thank you for the help
Hi  try adding  this line at line 10

jobName = $jobinfo.name;

Open in new window

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions