Powershell script for BackupExec

Kelly Garcia
Kelly Garcia used Ask the Experts™
on
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

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

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

Please can you try the following


I have reduced the data size to speed up testing by adding on line 1 " -first 3"   , which will just use the 1st three records I was also using the wrong variable   $mediainfo instead of $ID

Please try this and let me know
$mediainfo = Get-BEMedia | ? {$_.LastModifiedDate -ge (Get-Date).AddHours(-24)} | select -first 3 name, mediaset, mediasetid, lastmodifieddate, LocationName

$result=@()

foreach ($id in $mediainfo)
{

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


} # end foreach

$result | ft

Open in new window

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial