« Previous Next »

Not Answered Thread: 'Object reference not set to an instance of an object' error in IIS Powershell

Last post 06-12-2009 11:13 AM by Mike C. 18 replies.

Average Rating Rate It (5)

RSS

Page 2 of 2 (19 items) < Previous 1 2

Sort Posts:

  • 06-11-2009, 10:05 PM In reply to

    • sergeia
    • Top 100 Contributor
    • Joined on 04-14-2008, 8:47 PM
    • Posts 68

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

    Mike, I think what you see is the problem with access from PowerShell to your remote home holder.

    In my questions when I asked to show output from 'dir iis:\sites\parentSite' I meant 'parentSite' for your vdir, i.e. in your case it is 'Default Web Site'. And I suspect that you will get the same error.

    Now, when new-webvirtualdirectory is getting processed, PowerShell checks existance of its home folder. I see that you have this error:

    Output for dir \\alliance\dwebdfs02\iisapps\TestWACSFullTrust\1.1.0.0\:

    Get-ChildItem : Object reference not set to an instance of an object.

    It means you cannot access  home folder of your new vdir, and it causes an error. Please confirm if this is the case. If it is, then it is generic issue with PowerShell access to this folder, because this command above is executed on file system provider.

     

    --Sergei

     

     

  • 06-12-2009, 10:36 AM In reply to

    • Mike C
    • Not Ranked
    • Joined on 05-28-2009, 9:16 AM
    • Posts 13

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

    Hi Sergei,

    I didn't cover myself in glory there did I? :)

    Yes, if I perform the dir iis:\sites\default web site command (properly this time! :)) I get the same 'get-childitem' error as you describe.

    So, this makes me wonder which security context the dir command runs under because my user account (which I am using to run PowerShell) has the correct permissions to read the shares.  I can prove this by opening up the shares from the IIS machine in Explorer.

    I also tested this giving the 'everyone' account 'full control' to both the share and file permissions and received the same problem.

    Am I missing something (I expect so!).  I will try some more troubleshooting in the meantime.

    Continued thanks,

    Mike.

  • 06-12-2009, 11:08 AM In reply to

    • Mike C
    • Not Ranked
    • Joined on 05-28-2009, 9:16 AM
    • Posts 13

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

    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?

  • 06-12-2009, 11:13 AM In reply to

    • Mike C
    • Not Ranked
    • Joined on 05-28-2009, 9:16 AM
    • Posts 13

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

    Once again, hi Sergei,

    in addition to the two posts above. I have run the dir \\dwar02\wwwroot command on the W2K8 machine but in native Powershell rather than the IIS extension of Powershell.  And it works:

     PS C:\Users\mikec> dir \\dwar02\wwwroot


        Directory: \\dwar02\wwwroot


    Mode                LastWriteTime     Length Name
    ----                -------------     ------ ----
    d----        03/04/2009     10:41            aspnet_client
    -a---        03/04/2009     10:40        689 iisstart.htm
    -a---        03/04/2009     10:40     184946 welcome.png

    And this also works for all other shares on the network.

    Any help?

Page 2 of 2 (19 items) < Previous 1 2
Microsoft Communities