Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - Generating a drive function from a provider

Reply
 
Old 10-24-2007   #1 (permalink)
Darren Gosbell
Guest


 
 

Generating a drive function from a provider

I have been working on a provider for SQL Server Analysis Services and it is
coming across nicely. But if someone creates a new drive I would like to be
able to create a function that would enable them to navigate to the new drive
like you can with the built-in file system and registry drives.

eg.

# when someone types the following

new-psdrive ssas powerSSAS localhost

#I want to do the equivalent of typing the following

function ssas: { set-location ssas: }

Anyone know if this possible?
--
Darren Gosbell - SQL Server MVP
http://geekswithblogs.net/darrengosbell

My System SpecsSystem Spec
Old 10-24-2007   #2 (permalink)
Shay Levi
Guest


 
 

Re: Generating a drive function from a provider

It seems that it'll work

PS > function hkcu { set-location hkcu: }
PS > hkcu
PS HKCU:\>

This is a generic function to set locaion to any psdrive

#cdd = cd drive
function cdd {set-location $args[0]}

#test it

PS HKCU:\> cdd cert:
PS cert:\>


HTH

Shay
http://scriptolog.blogspot.com


Quote:

> I have been working on a provider for SQL Server Analysis Services and
> it is coming across nicely. But if someone creates a new drive I would
> like to be able to create a function that would enable them to
> navigate to the new drive like you can with the built-in file system
> and registry drives.
>
> eg.
>
> # when someone types the following
>
> new-psdrive ssas powerSSAS localhost
>
> #I want to do the equivalent of typing the following
>
> function ssas: { set-location ssas: }
>
> Anyone know if this possible?
>

My System SpecsSystem Spec
Old 10-24-2007   #3 (permalink)
Darren Gosbell
Guest


 
 

Re: Generating a drive function from a provider

Thanks, but I'm actually trying to find a way of doing this from .Net code
inside my provider class. So I can happily create the hard coded script I
want, but I have not been able to find a way of executing it.

--
Darren Gosbell - SQL Server MVP
http://geekswithblogs.net/darrengosbell


"Shay Levi" wrote:
Quote:

> It seems that it'll work
>
> PS > function hkcu { set-location hkcu: }
> PS > hkcu
> PS HKCU:\>
>
> This is a generic function to set locaion to any psdrive
>
> #cdd = cd drive
> function cdd {set-location $args[0]}
>
> #test it
>
> PS HKCU:\> cdd cert:
> PS cert:\>
>
>
> HTH
>
> Shay
> http://scriptolog.blogspot.com
>
>
>
Quote:

> > I have been working on a provider for SQL Server Analysis Services and
> > it is coming across nicely. But if someone creates a new drive I would
> > like to be able to create a function that would enable them to
> > navigate to the new drive like you can with the built-in file system
> > and registry drives.
> >
> > eg.
> >
> > # when someone types the following
> >
> > new-psdrive ssas powerSSAS localhost
> >
> > #I want to do the equivalent of typing the following
> >
> > function ssas: { set-location ssas: }
> >
> > Anyone know if this possible?
> >
>
>
>
My System SpecsSystem Spec
Old 10-24-2007   #4 (permalink)
Darren Gosbell
Guest


 
 

Re: Generating a drive function from a provider

I figured it out for anyone else who might be interested. Calling the
InvokeCommand.InvokeScript did the trick. I had tried that, but I was not
using this particular overload. I think the trick might be the second
parameter which controls the scope of the function.

InvokeCommand.InvokeScript(func, False, PipelineResultTypes.None, Nothing,
Nothing)

My PsDrive can now register it's own drive function shortcut.

--
Darren Gosbell - MVP
http://geekswithblogs.net/darrengosbell


"Darren Gosbell" wrote:
Quote:

> Thanks, but I'm actually trying to find a way of doing this from .Net code
> inside my provider class. So I can happily create the hard coded script I
> want, but I have not been able to find a way of executing it.
>
> --
> Darren Gosbell - SQL Server MVP
> http://geekswithblogs.net/darrengosbell
>
>
> "Shay Levi" wrote:
>
Quote:

> > It seems that it'll work
> >
> > PS > function hkcu { set-location hkcu: }
> > PS > hkcu
> > PS HKCU:\>
> >
> > This is a generic function to set locaion to any psdrive
> >
> > #cdd = cd drive
> > function cdd {set-location $args[0]}
> >
> > #test it
> >
> > PS HKCU:\> cdd cert:
> > PS cert:\>
> >
> >
> > HTH
> >
> > Shay
> > http://scriptolog.blogspot.com
> >
> >
> >
Quote:

> > > I have been working on a provider for SQL Server Analysis Services and
> > > it is coming across nicely. But if someone creates a new drive I would
> > > like to be able to create a function that would enable them to
> > > navigate to the new drive like you can with the built-in file system
> > > and registry drives.
> > >
> > > eg.
> > >
> > > # when someone types the following
> > >
> > > new-psdrive ssas powerSSAS localhost
> > >
> > > #I want to do the equivalent of typing the following
> > >
> > > function ssas: { set-location ssas: }
> > >
> > > Anyone know if this possible?
> > >
> >
> >
> >
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Loss of function of Start Orb + desktop, C Drive unable to transfer files now Vista performance & maintenance
Extracting drive, path, filebasename WITH string functions and NOT system function ??? VB Script
new Theme generating Virtual PC
AVI Thumbnails Not Generating Vista music pictures video
BUG: Redirecting function contents to a file truncates function lines at the width of the console PowerShell


Vista Forums 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 Ltd

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