View Complete Thread
  • 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.