Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum 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

can my cmdlet/snapin have a config file?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-11-2007   #1 (permalink)
Steve
Guest


 

can my cmdlet/snapin have a config file?

I just built a cmdlet/snapin for Powershell. it has a myCmdlet.dll.config
where it's installed. However, i'm not getting anything inside the cmdlet
when i do a:

COnfigurationManager.AppSettings["foobar"]

How do cmdlet configuration files work?

My System SpecsSystem Spec
Old 05-11-2007   #2 (permalink)
Keith Hill [MVP]
Guest


 

Re: can my cmdlet/snapin have a config file?

"Steve" <Steve@discussions.microsoft.com> wrote in message
news:97A43B65-7172-46CA-8A15-BBD83F68CC7A@microsoft.com...
>I just built a cmdlet/snapin for Powershell. it has a myCmdlet.dll.config
> where it's installed. However, i'm not getting anything inside the
> cmdlet
> when i do a:
>
> COnfigurationManager.AppSettings["foobar"]
>
> How do cmdlet configuration files work?


IIRC the ConfigurationManager.AppSetttings class works off an application
level config file. This is a common problem in .NET. There isn't a
framework supported config file for DLLs. BTW I would *not* recommend
dumping stuff into a PowerShell.exe.config file.

--
Keith


My System SpecsSystem Spec
Old 05-12-2007   #3 (permalink)
Joris van Lier
Guest


 

Re: can my cmdlet/snapin have a config file?


Blog: http://whizzrd.spaces.live.com

"Steve" <Steve@discussions.microsoft.com> wrote in message news:97A43B65-7172-46CA-8A15-BBD83F68CC7A@microsoft.com...
>I just built a cmdlet/snapin for Powershell. it has a myCmdlet.dll.config
> where it's installed. However, i'm not getting anything inside the cmdlet
> when i do a:
>
> COnfigurationManager.AppSettings["foobar"]
>
> How do cmdlet configuration files work?



I did something similar in a web app, Manually loading a config file from Assembly Path, that didn't work with GACed assemblies,
I believe assembly redirection policy configuration files are published in GAC by compiling them into an assembly as a resource, pretty useless for configuration as it's just as easy to change the code, recompile and re-publish as doing the same with a configuration file.

I know PSCX contain a method for associating cmdlet parameter default values to variables in the powershell environment, but haven't tried it yet.

Perhaps you can put the configuration into registry by attaching an eventhandler to the AfterInstall event your SnapIn inherits from Installer.
--
Joris van Lier
Please note that all scripts and opinions are supplied "as is" and with no warranty
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Powershell and cmdlet config files Steve PowerShell 3 05-14-2007 09:23 AM
How to set alias for my cmdlet when my snapin is registered Rostislav.Pridatko@quest.com PowerShell 1 03-16-2007 10:24 AM
what is the web.config file? geotso Vista General 6 11-04-2006 04:42 AM
adding a cmdlet without using a snapin klumsy@xtra.co.nz PowerShell 0 10-22-2006 03:52 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 51