I think you may be making this harder than it has to be. Gc the content into an
array of [string]. -imatch against SNAPSHOT ID and then +3 from that index is
your volume. SO...
$lines = gc <filename>
for ($i = 0; $i -lt $lines.Count; $i++)
{
If ($lines[$i] -imatch "^\* SNAPSHOT ID")
{
$volline = $lines[$i + 3]
...
}
}
Etc.etc.etc.
Regards,
Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com
From: Joseph L. Casale [mailto:[email protected]]
Sent: Friday, March 12, 2010 4:48 PM
To: NT System Admin Issues
Subject: RE: Powershell Question
Hey Michael,
Here is some of the output of two snapped drives (could be more):
* SNAPSHOT ID = {be35a053-2fee-4aa8-aa92-6bd1b2cf5e29} ...
- Shadow copy Set: {659a895d-1e31-4ef8-9909-ba8a21a143eb}
- Original count of shadow copies = 2
- Original Volume name:
\\?\Volume{787bdf7a-ccff-11dd-9866-806e6f6e6963}\<file:///\\%3f\Volume%7b787bdf7a-ccff-11dd-9866-806e6f6e6963%7d\>
[D:\]
- Creation Time: 3/12/2010 2:12:58 PM
- Shadow copy device name:
\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy13<file:///\\%3f\GLOBALROOT\Device\HarddiskVolumeShadowCopy13>
- Originating machine: localhost.localdomain
- Service machine: localhost.localdomain
- Not Exposed
- Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5}
- Attributes: No_Auto_Release Persistent Differential
* SNAPSHOT ID = {e87c8b85-6151-4ba8-bfa1-77b086b28dfc} ...
- Shadow copy Set: {659a895d-1e31-4ef8-9909-ba8a21a143eb}
- Original count of shadow copies = 2
- Original Volume name:
\\?\Volume{787bdf7b-ccff-11dd-9866-806e6f6e6963}\<file:///\\%3f\Volume%7b787bdf7b-ccff-11dd-9866-806e6f6e6963%7d\>
[E:\]
- Creation Time: 3/12/2010 2:12:58 PM
- Shadow copy device name:
\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy14<file:///\\%3f\GLOBALROOT\Device\HarddiskVolumeShadowCopy14>
- Originating machine: localhost.localdomain
- Service machine: localhost.localdomain
- Not Exposed
- Provider id: {b5946137-7b9f-4925-af80-51abd60b20d5}
- Attributes: No_Auto_Release Persistent Differential
I only know what SNAPSHOT ID to reference, and then expose if I grep this for
the Volume name "+3 lines back". So when I job this, and put its output in a
$JobOutput, I want to use $JobOutput for each volume that I expose to a drive
letter. That's the part I am unsure how to do.
Thanks!
jlc
From: Michael B. Smith [mailto:[email protected]]
Sent: Friday, March 12, 2010 2:42 PM
To: NT System Admin Issues
Subject: RE: Powershell Question
I'm going to say "yes", but I'm still not exactly sure what you are going for
there. Look at "-match", "findstr", and "select".
Regards,
Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com
From: Joseph L. Casale [mailto:[email protected]]
Sent: Friday, March 12, 2010 4:18 PM
To: NT System Admin Issues
Subject: Powershell Question
Hey guys,
I am converting a shell script into a ps script and need to parse a variable
that holds the output of an executed job.
at the cli (using unix tools) I do this:
grep -B 3 "some_string" |grep "another_string" |cut -f 5 -d " "
So basically, the output has many repetitions that have various fields
different, when I find the one I want, I include 3 lines up and filter that 3rd
up line to show what I want.
Is this possible using built in ps syntax?
Thanks,
jlc
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~