Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Connect-VIServer fails with "Object reference not set to an instance of an object" #585

@guyrleech

Description

@guyrleech

Describe the bug

Having connected to a vCenter server via Connect-VIserver, when the connection expires, Connect-VIserver will not work again in the same PowerShell instance
connect-viserver error
connect-viserver no error

Reproduction steps

1. Run script https://github.com/guyrleech/VMware/blob/master/VMware%20GUI.ps1 with -server <vcenterserver> and leave the launching PowerShell (v5.1 x64) window open
2. Authenticate to a vCenter server (7.0.3 in my case but not sure it is version specific)
3. Leave for 24 hours
4. Click "Refresh" in the script's GUI and observe to data and error in launching PowerShell window
5. Exit script
6. Launch script again from the same PowerShell window and observe reported error
7. Start a new PowerShell instance and verify script runs ok there (until some hours later when connection has timed out)

Expected behavior

Connect to the given Vcenter server

Additional context

Recently moved from a non-domain joined Windows 10 21H2 laptop where this issue never occurred to a domain-joined Windows 10 21H2 laptop (both where I logon as a non-local admin user and PowerShell is run non-elevated) where the issue occurs 100% of the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions