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

    Jun 08, 2009 08:35 AM|Mike C|LINK

    Hi Sergei,

    as I now have a few more commands (that you taught me!) I re-ran some of my tests.  I ran four scenarios with a new IIS7 server (DWAR02).  Each scenario had 5 tests, the results are below.

    The results confirm my findings, that when the physical path of the 'Default Web Site' is on a share I cannot run the create virtual directory command.  When the physical path is local, the command works fine.  There does not appear to be any issue with the location of the virtual directory itself (local or share) or the IIS config files.

    Interestingly the dir iis:\sites\parentsites command errors all the time, as does the dir command when looking at a share.

    DWAR02 Tests

    Stage 1 - IIS Standard build:

    IIS Config Physical Path: Local

    IIS Sites: Default Web Site

    Default Web Site Physical Path: %SystemDrive%\inetpub\wwwroot

    Test 1: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath c:\

    Outcome: Virtual Directory created successfully

    Test 2: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

    Outcome: Virtual Directory created successfully

    Test 3: dir file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

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

    Test 4: dir iis:\sites

    Outcome:

    Name             ID   State      Physical Path                  Bindings

    ----             --   -----      -------------                  --------

    Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:

    Test 5: dir iis:\sites\parentSites

    Outcome: Get-ChildItem : Cannot find path '\\DWAR02\sites\ParentSites' because it does not exist.

    Stage 2 - Added to Shared Config (as per previous post above):

    IIS Shared Config Physical Path: \\alliance\dwebdfs02\IISConfig\V1.0

    IIS Sites: Default Web Site

    Default Web Site Physical Path: \\alliance\dwebdfs02\iisapps\Root-DefaultWebSite\v1.0

    Test 1: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath c:\

    Outcome: New-Item : Object reference not set to an instance of an object. (Different from Stage 1)

    Test 2: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

    Outcome: New-Item : Object reference not set to an instance of an object. (Different from Stage 1)

    Test 3: dir file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

    Outcome: Get-ChildItem : Object reference not set to an instance of an object. (Same as Stage 1)

    Test 4: dir iis:\sites

    Outcome:

    Name             ID   State      Physical Path                  Bindings

    ----             --   -----      -------------                  --------

    Default Web Site 1    Started    file://alliance/\dwebdfs02\iisapps\R http *:80:

                                     oot-DefaultWebSite\v1.0

    Test 5: dir iis:\sites\parentSites

    Outcome: Get-ChildItem : Cannot find path ‘\\DWAR02\sites\ParentSites' because it does not exist. (Same as Stage 1)

    Stage 3 - Removed from Shared Config BUT retaining shared config settings:

    IIS Config Physical Path: Local

    IIS Sites: Default Web Site

    Default Web Site Physical Path: \\alliance\dwebdfs02\iisapps\Root-DefaultWebSite\v1.0

    Test 1: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath c:\

    Outcome: New-Item : Object reference not set to an instance of an object. (same as Stage 2)

    Test 2: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

    Outcome: New-Item : Object reference not set to an instance of an object. (Same as Stage 2)

    Test 3: dir file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

    Outcome: Get-ChildItem : Object reference not set to an instance of an object. (Same as Stage 1 and Stage 2)

    Test 4: dir iis:\sites

    Outcome:

    Name             ID   State      Physical Path                  Bindings

    ----             --   -----      -------------                  --------

    Default Web Site 1    Started    file://alliance/\dwebdfs02\iisapps\R http *:80:

                                     oot-DefaultWebSite\v1.0

    Test 5: dir iis:\sites\parentSites

    Outcome: Get-ChildItem : Cannot find path ‘\\DWAR02\sites\ParentSites' because it does not exist. (Same as Stage 1 and Stage 2)

    Stage 4 - Default Web Site physical path set local:

    IIS Config Physical Path: Local

    IIS Sites: Default Web Site

    Default Web Site Physical Path: %SystemDrive%\inetpub\wwwroot

    Test 1: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath c:\

    Outcome: Virtual Directory created successfully

    Test 2: new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

    Outcome: Virtual Directory created successfully

    Test 3: dir file://alliance/dwebdfs02/iisapps/TestWACSFullTrust/1.1.0.0/

    Outcome: Get-ChildItem : Object reference not set to an instance of an object. (Same as Stage 1 and Stage 2 and Stage 3)

    Test 4: dir iis:\sites

    Outcome:

    Name             ID   State      Physical Path                  Bindings

    ----             --   -----      -------------                  --------

    Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:

    Test 5: dir iis:\sites\parentSites

    Outcome: Get-ChildItem : Cannot find path ‘\\DWAR02\sites\ParentSites' because it does not exist. (Same as Stage 1 and Stage 2 and Stage 3)