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 - Powershell and cmdlet config files

Reply
 
Old 05-11-2007   #1 (permalink)
Steve


 
 

Powershell and cmdlet config files

I just wrote my first cmdlet. It uses a config file. The first time, i:

installutil mycmdlet.dll
Add-PSSnapIn mycmdlet

I set a breakpoint in the cmdlet, and verified that it read the config file
fine.

However, i made a change to the config file. I Removed the snapin, and
installutil -u the dll. Rebuild the dll and config file, reinstalled it,
but... it's not reading the changes to the config file.

What else do I need to do?



My System SpecsSystem Spec
Old 05-11-2007   #2 (permalink)
Don Jones [MVP]


 
 

Re: Powershell and cmdlet config files

Well, you don't *need* to uninstall it, really. Just close PowerShell and
drop the new DLL atop the old one.

And unfortunately the problem would be within your cmdlet code, not
something in PowerShell. I'm assumiung you're reading the config file in a
cmdlet's Begin method, correct?

--
Don Jones
Windows PowerShell MVP
Founder: www.ScriptingAnswers.com
Co-Author: "Windows PowerShell: TFM"

"Steve" <Steve@discussions.microsoft.com> wrote in message
news:CFFF3282-DC5C-4A93-9EB7-0A37C30957B5@microsoft.com...
>I just wrote my first cmdlet. It uses a config file. The first time, i:
>
> installutil mycmdlet.dll
> Add-PSSnapIn mycmdlet
>
> I set a breakpoint in the cmdlet, and verified that it read the config
> file
> fine.
>
> However, i made a change to the config file. I Removed the snapin, and
> installutil -u the dll. Rebuild the dll and config file, reinstalled it,
> but... it's not reading the changes to the config file.
>
> What else do I need to do?
>
>


My System SpecsSystem Spec
Old 05-11-2007   #3 (permalink)
Steve


 
 

Re: Powershell and cmdlet config files

Don, thanks.

I figured out the problem. I had a powershell.exe.config in the
windowspowershell bin directory.

I removed this file. Now, the question is:

Can cmdlets have config files? i'm not picking up any of the AppSettings now.

protected override void BeginProcessing()
{
username_ = String.Format(@"{0}\{1}",
ConfigurationManager.AppSettings["Domain"],
ConfigurationManager.AppSettings["AdminUser"]);
password_ = ConfigurationManager.AppSettings["Password"];
endpoint_ = ConfigurationManager.AppSettings["Endpoint"];
base.BeginProcessing();
}

"Don Jones [MVP]" wrote:

> Well, you don't *need* to uninstall it, really. Just close PowerShell and
> drop the new DLL atop the old one.
>
> And unfortunately the problem would be within your cmdlet code, not
> something in PowerShell. I'm assumiung you're reading the config file in a
> cmdlet's Begin method, correct?
>
> --
> Don Jones
> Windows PowerShell MVP
> Founder: www.ScriptingAnswers.com
> Co-Author: "Windows PowerShell: TFM"
>
> "Steve" <Steve@discussions.microsoft.com> wrote in message
> news:CFFF3282-DC5C-4A93-9EB7-0A37C30957B5@microsoft.com...
> >I just wrote my first cmdlet. It uses a config file. The first time, i:
> >
> > installutil mycmdlet.dll
> > Add-PSSnapIn mycmdlet
> >
> > I set a breakpoint in the cmdlet, and verified that it read the config
> > file
> > fine.
> >
> > However, i made a change to the config file. I Removed the snapin, and
> > installutil -u the dll. Rebuild the dll and config file, reinstalled it,
> > but... it's not reading the changes to the config file.
> >
> > What else do I need to do?
> >
> >

>

My System SpecsSystem Spec
Old 05-14-2007   #4 (permalink)
Don Jones [MVP]


 
 

Re: Powershell and cmdlet config files

Since snap-ins are DLLs, no - only EXEs can have 'em.

--
Don Jones
Windows PowerShell MVP
Founder: www.ScriptingAnswers.com
Co-Author: "Windows PowerShell: TFM"

"Steve" <Steve@discussions.microsoft.com> wrote in message
news:AB1891DA-ECEC-4D6B-A705-436B024DB74E@microsoft.com...
> Don, thanks.
>
> I figured out the problem. I had a powershell.exe.config in the
> windowspowershell bin directory.
>
> I removed this file. Now, the question is:
>
> Can cmdlets have config files? i'm not picking up any of the AppSettings
> now.
>
> protected override void BeginProcessing()
> {
> username_ = String.Format(@"{0}\{1}",
> ConfigurationManager.AppSettings["Domain"],
> ConfigurationManager.AppSettings["AdminUser"]);
> password_ = ConfigurationManager.AppSettings["Password"];
> endpoint_ = ConfigurationManager.AppSettings["Endpoint"];
> base.BeginProcessing();
> }
>
> "Don Jones [MVP]" wrote:
>
>> Well, you don't *need* to uninstall it, really. Just close PowerShell and
>> drop the new DLL atop the old one.
>>
>> And unfortunately the problem would be within your cmdlet code, not
>> something in PowerShell. I'm assumiung you're reading the config file in
>> a
>> cmdlet's Begin method, correct?
>>
>> --
>> Don Jones
>> Windows PowerShell MVP
>> Founder: www.ScriptingAnswers.com
>> Co-Author: "Windows PowerShell: TFM"
>>
>> "Steve" <Steve@discussions.microsoft.com> wrote in message
>> news:CFFF3282-DC5C-4A93-9EB7-0A37C30957B5@microsoft.com...
>> >I just wrote my first cmdlet. It uses a config file. The first time,
>> >i:
>> >
>> > installutil mycmdlet.dll
>> > Add-PSSnapIn mycmdlet
>> >
>> > I set a breakpoint in the cmdlet, and verified that it read the config
>> > file
>> > fine.
>> >
>> > However, i made a change to the config file. I Removed the snapin, and
>> > installutil -u the dll. Rebuild the dll and config file, reinstalled
>> > it,
>> > but... it's not reading the changes to the config file.
>> >
>> > What else do I need to do?
>> >
>> >

>>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Accessing powershell cmdlet via rsh PowerShell
Powershell.exe.config PowerShell
XML processing my web.config file in PowerShell PowerShell
get-service cmdlet in powershell v2 (ctp) PowerShell
can my cmdlet/snapin have a config file? 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