Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Taking ownership of script members?

Closed Thread
 
Thread Tools Display Modes
Old 03-22-2007   #1 (permalink)
Duncan Smith
Guest


 

Taking ownership of script members?

I have a script called getMyXmlFromDB.ps1 which retrieves some xml
data from an sqlxml website - it works well, but I'd also like to be
able to manipulate the dom object after the script has run - my guess
is that the dom is being destroyed when the script finishes as it goes
out of scope or something.

Can I instruct the shell to inherit the data/objects of the running
script?

Thanks,

Duncan.

Here's the script:

---
#.\getMyXmlFromDB.ps1

"running getMyXmlFromDB.ps1"

# get data from the database into a DOM
$friStr = "<root>"
$friStr += Get-url "http://barsql01/mydatabase?sql=exec GetMyData_sp
@p_strEvent='EvCode', @p_strSeason='2007', @p_strMinTime='2007-03-15
00:00:00', @p_strMaxTime='2007-03-16 23:59:59'"
$friStr += "</root>"

[xml]$friXml = $friStr

echo $friXml

# pretty-print and write to a file
fxml -InputObject $fri > fri.xml
---

Old 03-22-2007   #2 (permalink)
/\\/\\o\\/\\/ [MVP]
Guest


 

Re: Taking ownership of script members?

you can dot source the script to load it into the global (interactive) scope
:

.. .\getMyXmlFromDB.ps1

note the dot and space before the scriptpath

Greetings /\/\o\/\/

"Duncan Smith" <DSmith1974@googlemail.com> wrote in message
news:1174580108.193401.44640@n76g2000hsh.googlegroups.com...
>I have a script called getMyXmlFromDB.ps1 which retrieves some xml
> data from an sqlxml website - it works well, but I'd also like to be
> able to manipulate the dom object after the script has run - my guess
> is that the dom is being destroyed when the script finishes as it goes
> out of scope or something.
>
> Can I instruct the shell to inherit the data/objects of the running
> script?
>
> Thanks,
>
> Duncan.
>
> Here's the script:
>
> ---
> #.\getMyXmlFromDB.ps1
>
> "running getMyXmlFromDB.ps1"
>
> # get data from the database into a DOM
> $friStr = "<root>"
> $friStr += Get-url "http://barsql01/mydatabase?sql=exec GetMyData_sp
> @p_strEvent='EvCode', @p_strSeason='2007', @p_strMinTime='2007-03-15
> 00:00:00', @p_strMaxTime='2007-03-16 23:59:59'"
> $friStr += "</root>"
>
> [xml]$friXml = $friStr
>
> echo $friXml
>
> # pretty-print and write to a file
> fxml -InputObject $fri > fri.xml
> ---
>


Old 03-22-2007   #3 (permalink)
Duncan Smith
Guest


 

Re: Taking ownership of script members?

On Mar 22, 5:58 pm, "/\\/\\o\\/\\/ [MVP]" <mow...@hotmail.NoSpam>
wrote:
> you can dot source the script to load it into the global (interactive) scope
> :
>
> . .\getMyXmlFromDB.ps1
>
> note the dot and space before the scriptpath
>
> Greetings /\/\o\/\/
>
> "Duncan Smith" <DSmith1...@googlemail.com> wrote in message
>
> news:1174580108.193401.44640@n76g2000hsh.googlegroups.com...
>
> >I have a script called getMyXmlFromDB.ps1 which retrieves some xml
> > data from an sqlxml website - it works well, but I'd also like to be
> > able to manipulate the dom object after the script has run - my guess
> > is that the dom is being destroyed when the script finishes as it goes
> > out of scope or something.

>
> > Can I instruct the shell to inherit the data/objects of the running
> > script?

>
> > Thanks,

>
> > Duncan.

>
> > Here's the script:

>
> > ---
> > #.\getMyXmlFromDB.ps1

>
> > "running getMyXmlFromDB.ps1"

>
> > # get data from the database into a DOM
> > $friStr = "<root>"
> > $friStr += Get-url "http://barsql01/mydatabase?sql=execGetMyData_sp
> > @p_strEvent='EvCode', @p_strSeason='2007', @p_strMinTime='2007-03-15
> > 00:00:00', @p_strMaxTime='2007-03-16 23:59:59'"
> > $friStr += "</root>"

>
> > [xml]$friXml = $friStr

>
> > echo $friXml

>
> > # pretty-print and write to a file
> > fxml -InputObject $fri > fri.xml
> > ---


That's great, thanks :-)

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Taking Ownership KingOfChaos General Discussion 1 04-08-2008 02:12 PM
Taking Ownership of a 2nd Hard Drive Rohan Vista security 1 12-09-2007 04:35 AM
taking ownership of system 32 files maxvista Vista General 3 12-02-2007 04:36 PM
What would the effect be of taking ownership of a drive? JD Vista account administration 3 11-14-2006 09:01 PM
Taking Ownership? Paula Vista General 39 09-10-2006 02:46 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50