An unhandled exception of type 'System.Management.Automation.CmdletProviderInvocationException' occurred in System.Management.Automation.dll

An unhandled exception of type 'System.Management.Automation.CmdletProviderInvocationException' occurred in System.Management.Automation.dll Additional information: Index was outside the bounds of the array



>> once you try to load power shell script through c# program, some times you may get this generic error
     and if you go to the stack trace you will get the error details

    Attempting to perform the NewItem operation on the 'WebAdministration' provider failed for the path
    '\\\\server-  name\\Sites\\websitename'   Index was outside the bounds of the array.

   If you debug the application you will find difficulty  to figure out the route cause, I have faced this issue an as per my research in google got the solution so thought of posting it in blog

Solution : If you are trying to create new website using powershell and the IIS dosenot have any default website you will get this error message

by default default website will be there, if you remove that by mistake you will get this message, So resolution is add one dummy website.


/* androidsharp */

0 comments: