View Complete Thread
  • Re: 'Object reference not set to an instance of an object' error in IIS Powershell

    Jun 12, 2009 11:08 AM|Mike C|LINK

    Hi Sergei,

    in addition to the post above, I have done a quick test.

    I set the 'Default Web Site' root to C:\inetpub\wwwroot and ran the dir 'iis:/sites/default web site' command, and this returned a list of files in that directory.

    I then shared the wwwroot directory (sharename wwwroot) and changed the 'Default Web Site' physical path to this (so '\\DWAR02\wwwroot'.  I changed the 'connect as' account to my domain administrator account.  When I now run the dir 'iis:/sites/default web site' command I get:

    PS IIS:\> dir 'iis:\sites\default web site'
    Get-ChildItem : Cannot find path '\\dwar02\wwwroot' because it does not exist.
    At line:1 char:4
    + dir <<<<  'iis:\sites\default web site'
        + CategoryInfo          : ObjectNotFound: (\\dwar02\wwwroot:String) [Get-ChildItem], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand 

    I get the same error if I run dir \\dwar02\wwwroot command, or the dir command to any share on our network. 

    I can map a drive to '\\dwar02\wwwroot', open it explorer and IIS seems more that happy with that as the root (I can get to the the iisstart.htm page if I surf to the default web site).

    Interestingly I have just run the dir \\dwar02\wwwroot command on Powershell v1.0 on a W2K3 64 bit machine (one of our Exchange 2007 servers) and it works fine.  So Powershell on the W2K8 machines seems to be the problem.

    Can you recreate this?