IS add-pssnapin for IIS provider always required??RSS

5 replies

Last post Apr 15, 2008 06:34 PM by JeongHwan

‹ Previous Thread|Next Thread ›
  • IS add-pssnapin for IIS provider always required??

    Apr 15, 2008 02:13 PM|ma_khan|LINK

    Hello Ppl,

    Is it always required to do a add-pssnapin for PS IIS Provider everytime I start a new session of Windows PowerShell.

    Everytime I try any cmdlet for PS IIS provider it throws as error, but, once I do a add-pssnapin  for the IIS provider everything gets into place and all is well..

    what am I missing here???  

    iis 7 PowerShell

  • JeongHwan JeongHwan

    50 Posts

    Microsoft

    Moderator

    Re: IS add-pssnapin for IIS provider always required??

    Apr 15, 2008 02:30 PM|JeongHwan|LINK

    No, you aren't missing anything.

    If you started Powershell prompt or shell without using the short-cut menu which is created by the IIS Powershell Provider setup program, you have to add the IIS snap-in to your shell using the add-pssnapin cmdlet. If you see the property of IIS Powershell Management console short-cut menu, it would look like this. 

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files\IIS\PowerShellProvider\IIsConsole.psc1" -NoExit -command set-location IIS:\;clear-host

    Actually it does exactly the same thing of the cmdlet execution of "add-pssnapin IIsProviderSnapIn". The short-cut menu is made for user's convenience in order not to need to execute the add-pssnapin command everytime when the Powershell prompt is started.

    Jeong Hwan Kim
  • Re: IS add-pssnapin for IIS provider always required??

    Apr 15, 2008 02:50 PM|ma_khan|LINK

    JeongHwan,

        Yeah just noticed that... but is it not possible that we can add the IIS provider permanently into Windows PowerShell so that we dont have to always do a add-pssnapin ...Of course there is always the IIS PowerShell Managment Console... but just a query :D
     

  • JeongHwan JeongHwan

    50 Posts

    Microsoft

    Moderator

    Re: IS add-pssnapin for IIS provider always required??

    Apr 15, 2008 04:26 PM|JeongHwan|LINK

    Hi ma_khan, 

    I had the same question and contacted the Powershell team in Microsoft but the answer was that there is no way to add IIS Provider snapin permanently.

    JeongHwan

    Jeong Hwan Kim
  • Re: IS add-pssnapin for IIS provider always required??

    Apr 15, 2008 05:10 PM|AlastairSmith|LINK

    You can do this by adding the line Add-PSSnapIn IIsProviderSnapIn to your profile.ps1 script.  This script is executed each time you start a new PowerShell session (like a .bashrc or .bash_profile script in *nix land). 

    The script doesn't exist by default, so you need to create a new PowerShell script called profile.ps1 in My Documents\WindowsPowerShell.  This is just like any other PowerShell script, so you can fill it with all sorts of useful things.  For example, I have another script called profile_alias.ps1 that sets up some useful aliases in my PowerShell session (e.g., edit -> text editor) which I dot-source from my profile.ps1 script.

    Hope that helps

    Alastair
     

  • JeongHwan JeongHwan

    50 Posts

    Microsoft

    Moderator

    Re: IS add-pssnapin for IIS provider always required??

    Apr 15, 2008 06:34 PM|JeongHwan|LINK

    Thanks Alastair. You gave better answer than mine. :-)

    Jeong Hwan Kim
‹ Previous Thread|Next Thread ›