'Object reference not set to an instance of an object' error in IIS PowershellRSS

19 replies

Last post Jul 20, 2010 08:35 AM by mike cracknell

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

    May 28, 2009 09:27 AM|Mike C|LINK

    Hi,

    I am new to powershell, I'm looking at it to start streamlining admin tasks on our IIS 7 servers.  When I attempt to run new-item or new-webvirtualdirectory commands I receive the error 'Object reference not set to an instance of an object' error.

    Now, this only appears to happen on IIS servers that have shared config, I have tested the same command on a standalone IIS box and it works with no problem.

    I wonder if I am doing something fundamentally wrong, should I be able to use IIS Powershell to script against a shared config set up?  If so, has anyone seen (and fixed) this issue before?

    The command I am running is:

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

    The error is:

    New-Item : Object reference not set to an instance of an object.

    I will try some troubleshooting to see if this is a permissions issue but any assistance would be gratefully received.

    Regards,

    Mike.

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

    May 29, 2009 10:50 AM|Mike C|LINK

    An update - I have taken a shared config IIS server and reverted it back to local config and I still get the problem.  On all our other IIS 7 servers (which have never had shared config) the command works perfectly.  So the shared config thing might be a red herring.

    Next step - to try and recreate the problem on new servers by rebuilding step by step.

    In the meantime, if anyone has any insights they would be gratefully received.

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

    Jun 02, 2009 08:06 AM|Mike C|LINK

    Another update.  I have tested the following scenarios (all shares are on DFS):

    1. Shared IIS config & shared site files - I get the error.

    2. Local IIS config & local site files - Powershell works fine.

    3. Shared IIS config & local site files - Powershell works fine.

    So the problem appears to lie with using a share to store the site files.

    I will continue to investigate (a security problem perhaps?), in the meantime any help would be appreciated.  Maybe even a 'hello' would do :)

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

    Jun 02, 2009 08:59 AM|Mike C|LINK

    Microsoft - Please Help!

    I have tested a non-DFS share with 'Everyone-Full Control' on both the share and file permissions and the command still returns the error. 

    I have reached the end of my troubleshooting with the following conclusion:

    The new-webvirtualdirectory command returns the error 'New-Item : Object reference not set to an instance of an object.' when the root of the site is held on a share rather than locally.

    I can recreate this problem and it looks to my untrained eye as though the command cannot deal with the '\\server\share' structure when it comes to the root of the site.

    Microsoft, is there any chance you can have a look at this?  My IIS 7 design uses (DFS) shares for all config to ease management so this is a bit of a show stopper.  Thanks, Mike.

     

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

    Jun 03, 2009 12:59 PM|sergeia|LINK

    Mike, could you please run it again and then post output from

    variable $error[0].Exception.StackTrace?

    This will point me to the location where null pointer is getting hit.

     

    Thanks,

    Sergei

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

    Jun 03, 2009 01:39 PM|sergeia|LINK

    Mike, please tell which installation of IIS snapin do you use, is it installed from the Web site or coming with Windows 7 RC? Also, what kind of connections do you have between two computers, are they joined to domain or members of workgroup? I cannot reproduce this problem between two machines from workgroup, when I point vdir home to the public share of remote server, like \\server_name\users.

     

     Thanks,

    --Sergei

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

    Jun 04, 2009 04:17 AM|Mike C|LINK

    Hi Sergei,

    I downloaded and installed the IIS Powershell snapin from the website (64 bit edition).  Is it possible I am using thw wrong version?  How can I tell?

    The computers are part of a domain.

    I am going to show my ignorance here, how do I get the output from 'variable $error[0].Exception.StackTrace' when I reproduce the error?

    Thanks for your assistance,

    Mike.

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

    Jun 04, 2009 05:31 AM|Mike C|LINK

    Hi Sergei, with the help of a few blogs I managed to get the following information from the error:

    Exception             : System.NullReferenceException: Object reference not set to an instance of an object.                           at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.GetNormalizedRelativePath(String                        path, String basePath)                           at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.ItemExists(String path)                           at System.Management.Automation.Provider.ItemCmdletProvider.ItemExists(String path, CmdletPr                        oviderContext context)                           at System.Management.Automation.SessionStateInternal.ItemExists(CmdletProvider providerInsta                        nce, String path, CmdletProviderContext context)TargetObject          :CategoryInfo          : NotSpecified: (:) [New-Item], NullReferenceExceptionFullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.NewItemCommandErrorDetails          :InvocationInfo        : System.Management.Automation.InvocationInfo  MyCommand        : New-ItemScriptLineNumber : 0OffsetInLine     : 0ScriptName       :Line             :PositionMessage  :InvocationName   :PipelineLength   : 1PipelinePosition : 1 00000000000000000000000000000000000000000000000000000000000000000000000000000000 Message        : Object reference not set to an instance of an object.Data           : {}InnerException :TargetSite     : System.String GetNormalizedRelativePath(System.String, System.String)StackTrace     :    at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.GetNormalizedRelativePath(String path, S                 tring basePath)                    at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.ItemExists(String path)                    at System.Management.Automation.Provider.ItemCmdletProvider.ItemExists(String path, CmdletProviderC                 ontext context)                    at System.Management.Automation.SessionStateInternal.ItemExists(CmdletProvider providerInstance, St                 ring path, CmdletProviderContext context)HelpLink       :Source         : Microsoft.IIS.Powershell.Provider 

    Is this any help?

    Mike.

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

    Jun 04, 2009 07:08 AM|Mike C|LINK

    Sergei,

    it is probably worth me being a little clearer on the problem.  The issue only occurs when the web site (e.g. Default Web Site) is set to a share.  Virtual directories under the web site are fine whether they are local or on a share.

     

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

    Jun 04, 2009 01:46 PM|sergeia|LINK

    Mike, you are doing great, but something is still missing here. I still cannot reproduce this issue. And I don't see that ItemExists (that you have in your stack trace) is getting called during processing of new-webvirtualdirectory.

    Let's start full scale attack on this. Please provide answers to following questions:

    1. Which version of PowerShell are you using? Is it version 1 or version 2?

    2. Please describe your setup in full details, you could use any names, I am interested in 'topology': which share is used for configuration, which share is used for parent site home path, which share is passed as home for new vdir?

    3. Make sure you could see the site and folder under it. Run 'dir iis:\sites' and 'dir iis:\sites\parentSite' -- there should be no errors.

    4. Make sure you could see home folder for new vdir. For this share please run 'dir \\machine\share' -- there should be no errors.

    5. Please provide full command line you are using for new vdir, including prompt, like 'PS C:\ #> new-webvirtualdirectory -site testSite -name shared2 -physicalpath \\sergeia-dev32\config'.

    6. After you get an error, please type '$StackTrace' and show me output from it. $StackTrace is PowerShell global variable that is shortcut for $error[0].Exception.StackTrace, and contains managed stack trace for the last error that happened. Previous one will be in $error[1], etc.

     

    Thanks,

    Sergei

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

    Jun 08, 2009 04:41 AM|Mike C|LINK

    Hi Sergei,

    thanks for your continued assistance, the answers (hopefully) to your questions are below.  There are some errors which I have highlighted in bold.  I have also provided the $StackTrace for each of these errors at the end.

    1. Which version of PowerShell are you using? Is it version 1 or version 2?

    PS IIS:\> get-host

    Name             : ConsoleHost

    Version          : 1.0.0.0

    InstanceId       : 6f6cc0c1-9373-4b94-b69d-669f6669bc43

    UI   : System.Management.Automation.Internal.Host.InternalHostUserInterface

    CurrentCulture   : en-GB

    CurrentUICulture : en-US

    PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy

     

    2. Please describe your setup in full details, you could use any names, I am interested in 'topology': which share is used for configuration, which share is used for parent site home path, which share is passed as home for new vdir?

    2 x W2K8 SP1 DFS servers: DWEB04 and DWEB05

    DFS Namespace: \\alliance\DWEBDFS02

    DFS Shares: IISConfig, IISApps

    2 x W2K8 SP1 IIS servers: DWEB07 and DWEB08

    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

    New Virtual Directory Physical Path – Have tried the following (both local and shared) and still get the error:

    -      C:\

    -      \\alliance\dwebdfs02\iisapps\TestWACSFullTrust\1.1.0.0\

    3. Make sure you could see the site and folder under it. Run 'dir iis:\sites' and 'dir iis:\sites\parentSite' -- there should be no errors.

    Output from ‘dir iis:sites’:

    Name             ID   State      Physical Path                  Bindings

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

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

                                     oot-DefaultWebSite\v1.0

    Output from ‘dir iis:\sites\parentSites’

    Get-ChildItem : Cannot find path '\\DWEB07\sites\parentSites' because it does not exist.

    At line:1 char:4

    + dir  <<<< iis:\sites\parentSites:

     

    4. Make sure you could see home folder for new vdir. For this share please run 'dir \\machine\share' -- there should be no errors.

    Output for dir c:\

        Directory: Microsoft.PowerShell.Core\FileSystem::C:\

    Mode                LastWriteTime     Length Name

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

    d----        03/04/2009     10:57            inetpub

    d----        19/01/2008     10:11            PerfLogs

    d-r--        29/05/2009     15:20            Program Files

    d-r--        07/05/2009     14:31            Program Files (x86)

    d----        15/05/2009     12:39            temp

    d-r--        20/05/2009     15:19            Users

    d----        20/05/2009     15:20            Windows

    -ar-s        03/04/2009     19:06       8192 BOOTSECT.BAK

    -a---        22/04/2009     10:29         21 tmuninst.ini

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

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

    At line:1 char:4

    + dir  <<<< \\alliance\dwebdfs02\iisapps\TestWACSFullTrust\1.1.0.0\

    (Note, if I browse to this location in Explorer I can see it with no problem.  I have tried this command against a number of DFS and non-DFS shares on our network and I get the same error.)

     

    5. Please provide full command line you are using for new vdir, including prompt, like 'PS C:\ #> new-webvirtualdirectory -site testSite -name shared2 -physicalpath \\sergeia-dev32\config'.

    PS IIS:\> new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath c:\

    PS IIS:\> new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath \\alliance\dwebdfs02\iisapps\TestWACSFullTrust\1.1.0.0\

     

    6. After you get an error, please type '$StackTrace' and show me output from it. $StackTrace is PowerShell global variable that is shortcut for $error[0].Exception.StackTrace, and contains managed stack trace for the last error that happened. Previous one will be in $error[1], etc.

    The output from each of the errors I received going through these six steps:

    Command - PS IIS:\> new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath c:\

    Error trace - PS IIS:\> $StackTrace

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.GetNormalizedRelativePath(String path, String basePath)

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.ItemExists(String path)

       at System.Management.Automation.Provider.ItemCmdletProvider.ItemExists(String path, CmdletProviderContext context)

       at System.Management.Automation.SessionStateInternal.ItemExists(CmdletProvider providerInstance, String path, CmdletProviderContext context)

    Command – PS IIS:\> new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath \\alliance\dwebdfs02\iisapps\TestWACSFullTrust\1.1.0.0\

    Error trace - PS IIS:\> $StackTrace

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.GetNormalizedRelativePath(String path, String basePath)

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.ItemExists(String path)

       at System.Management.Automation.Provider.ItemCmdletProvider.ItemExists(String path, CmdletProviderContext context)

       at System.Management.Automation.SessionStateInternal.ItemExists(CmdletProvider providerInstance, String path, CmdletProviderContext context)

    Command - PS IIS:\> dir \\alliance\dwebdfs02\iisapps\TestWACSFullTrust\1.1.0.0\

    Error trace - PS IIS:\> $StackTrace

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.GetNormalizedRelativePath(String path, String basePath)

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.ItemExists(String path)

       at System.Management.Automation.Provider.ItemCmdletProvider.ItemExists(String path, CmdletProviderContext context)

       at System.Management.Automation.SessionStateInternal.ItemExists(CmdletProvider providerInstance, String path, Cmdlet

    ProviderContext context)

    Command - PS IIS:\> dir iis:\sites\parentSites

    Error Trace - PS IIS:\> $StackTrace

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.GetNormalizedRelativePath(String path, String basePath)

       at Microsoft.IIs.PowerShell.Provider.ConfigurationProvider.ItemExists(String path)

       at System.Management.Automation.Provider.ItemCmdletProvider.ItemExists(String path, CmdletProviderContext context)

       at System.Management.Automation.SessionStateInternal.ItemExists(CmdletProvider providerInstance, String path, CmdletProviderContext context)

    I hope this all helps!

    Mike.

  • 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)

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

    Jun 09, 2009 04:08 AM|Mike C|LINK

    Hi Sergei,

    I have installed Powershell 2.0 CTP3 on one of the IIS servers and I still have the same problem (although the error reporting is better!):

    PS IIS:\> new-webvirtualdirectory -site "Default Web Site" -name MCTest -physicalpath c:\
    New-Item : Object reference not set to an instance of an object.
        + CategoryInfo          : NotSpecified: (:) [New-Item], NullReferenceException
        + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.NewItemCommand

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

    Jun 09, 2009 11:13 AM|sergeia|LINK

    Mike, do you mind to provide answers to questions I asked you in my last reply? Without looking at the wider picture we cannot move forward, just sending me failed command doesn't help -- I need more complete description of your setup.

    Thanks,

    Sergei

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

    Jun 09, 2009 11:15 AM|sergeia|LINK

    Nevermind, I see that you already sent these replies. I will try to reproduce it here.

    --Sergei

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

    Jun 11, 2009 10:05 PM|sergeia|LINK

    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

     

     

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

    Jun 12, 2009 10:36 AM|Mike C|LINK

    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.

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

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

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

    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?

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

    Jul 20, 2010 08:35 AM|Mike Cracknell|LINK

    For info, I never got the bottom of this problem.  However W2K8 R2 works a treat, without this problem.  The IIS/Powershell integration in R2 seems to be a lot more robust.