locked
IS add-pssnapin for IIS provider always required?? RRS feed

  • Question

  • User-1341446551 posted

    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???  

    Tuesday, April 15, 2008 2:13 PM

All replies

  • User1331732461 posted

    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.

    Tuesday, April 15, 2008 2:30 PM
  • User-1341446551 posted

    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
     

    Tuesday, April 15, 2008 2:50 PM
  • User1331732461 posted

    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

    Tuesday, April 15, 2008 4:26 PM
  • User1121220086 posted

    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
     

    Tuesday, April 15, 2008 5:10 PM
  • User1331732461 posted

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

    Tuesday, April 15, 2008 6:34 PM