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.
Kelly GarciaSenior Systems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joe KlimisCommented:
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

0
Joe KlimisCommented:
Hi Kay
have you tried this yet ?  how did you get on
Joe
0
Kelly GarciaSenior Systems AdministratorAuthor Commented:
apologies I will do this today, I was running it last week but it was taking ages
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

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

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

Open in new window

0
Joe KlimisCommented:
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kelly GarciaSenior Systems AdministratorAuthor Commented:
how do I get the job name?
0
Kelly GarciaSenior Systems AdministratorAuthor Commented:
were almost there, thank you for the help
0
Joe KlimisCommented:
Hi  try adding  this line at line 10

jobName = $jobinfo.name;

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.