Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-AsBuiltReport : You cannot call a method on a null-valued expression. #19

Closed
3 tasks done
spaceghostcowboy opened this issue Jul 6, 2023 · 8 comments · Fixed by #20
Closed
3 tasks done
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@spaceghostcowboy
Copy link

Bug description

I was able to run a few reports without issue. For what seems to be no reason the command to run the report errors out with

New-AsBuiltReport : You cannot call a method on a null-valued expression. and it points to the first line of the command to call the report example New-AsBuiltReport -Report VMware.SRM -Target 192.168.5.16 -Credential $Creds -Format Html,Text -OutputFolderPath 'C:\Users\Jon\Documents' -EnableHealthCheck the error would point to the first char at this line.

When I run the command verbose it successfully connects to the vcenter and gets to the point where is obtaining SRM licensing information. The command then stops with the provided error message.

Command-line input

New-AsBuiltReport -Report VMware.SRM -Target 192.168.5.16 -Credential $Creds -Format Html,Text -OutputFolderPath 'C:\Users\Jon\Documents'

Steps to reproduce

1.) run the cmdlet New-AsBuiltReport -Report VMware.SRM -Target 192.168.5.16 -Credential $Creds -Format Html,Text -OutputFolderPath 'C:\Users\Jon\Documents'

Expected behaviour

I expected the cmdlet to run without error and output my report successfully to the given output folder.

Screenshots

No response

Operating System

Windows Server 2012R2

PowerShell Version

5.1

PowerShell Modules

AsBuiltReport.Core 1.3.0
AsBuiltReport.VMware.SRM 0.4.2
PScribo 0.10.0

Additional Context

No response

Before submitting

@spaceghostcowboy spaceghostcowboy added the bug Something isn't working label Jul 6, 2023
@spaceghostcowboy
Copy link
Author

If I disable the SRM license check portion the report runs fine. Lol this happens to be the thing I was most concerned about of course.

@spaceghostcowboy
Copy link
Author

spaceghostcowboy commented Jul 6, 2023

Does this module gather the SRM lic information by this command Get-AbrSRMLicense ? or is that an alias you created?

@rebelinux
Copy link
Collaborator

I tested the report in two different SRM environments and could not replicate the error you report.

Can you run the following commands and send me the results? Be sure to hide the private information.

# Set Credentials 
$password = ConvertTo-SecureString "CHANGEME" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ("administrator@vsphere.local", $password)

# Connect to local vcenter
$LocalvCenter = Connect-VIServer -Server "CHANGEME"  -Credential $Cred -ErrorAction Stop

# Connect to local srm
$LocalSRM = Connect-SrmServer -IgnoreCertificateErrors -Verbose -Debug -Server $LocalvCenter -Credential $cred -Port 443 -Protocol https -RemoteCredential $cred

# Connect to remote vcenter
$RemotevCenter = Connect-VIServer $LocalSRM.ExtensionData.GetPairedSite().vcHost -Credential $Cred -ErrorAction Stop

# Connect to remote srm
$RemoteSRM = Connect-SrmServer -IgnoreCertificateErrors -Server $RemotevCenter -Credential $Cred -Port 443 -Protocol https -RemoteCredential $Cred

# Get Local SRM License Information
$LocalSRM.ExtensionData.GetLicenseInfo()

# Get Remote SRM License Information
$RemoteSRM.ExtensionData.GetLicenseInfo()

@rebelinux rebelinux added the question Further information is requested label Jul 6, 2023
@rebelinux
Copy link
Collaborator

@spaceghostcowboy
Copy link
Author

Yes I can thank you for the response I will plan to test today.

@spaceghostcowboy
Copy link
Author

PS C:\Users\username > $LocalvCenter = Connect-VIServer -Server "servername" -Credential $Cred -ErrorAction Stop

PS C:\Users\username > $LocalSRM = Connect-SrmServer -IgnoreCertificateErrors -Verbose -Debug -Server $LocalvCenter -Credential $cred -Port 443 -Protocol https -RemoteCredential $cred
DEBUG: 7/10/2023 3:42:59 PM Connect-SrmServer serverid
VERBOSE: 7/10/2023 3:43:01 PM Connect-SrmServer Finished execution
DEBUG: 7/10/2023 3:43:01 PM Connect-SrmServer

PS C:\Users\username > $RemotevCenter = Connect-VIServer $LocalSRM.ExtensionData.GetPairedSite().vcHost -Credential $Cred -ErrorAction Stop
Exception calling "GetPairedSite" with "0" argument(s): "The session is not authenticated."
At line:1 char:1

  • $RemotevCenter = Connect-VIServer $LocalSRM.ExtensionData.GetPairedSi ...
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : VimException
    
    
    

PS C:\Users\username > $RemoteSRM = Connect-SrmServer -IgnoreCertificateErrors -Server $RemotevCenter -Credential $Cred -Port 443 -Protocol https -RemoteCredential $Cred

PS C:\Users\username > $LocalSRM.ExtensionData.GetLicenseInfo()
Exception calling "GetLicenseInfo" with "0" argument(s): "The session is not authenticated."
At line:1 char:1

  • $LocalSRM.ExtensionData.GetLicenseInfo()
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : VimException
    
    
    

PS C:\Users\username > $RemoteSRM.ExtensionData.GetLicenseInfo()
Exception calling "GetLicenseInfo" with "0" argument(s): "The session is not authenticated."
At line:1 char:1

  • $RemoteSRM.ExtensionData.GetLicenseInfo()
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : VimException
    
    

@AGH2021
Copy link

AGH2021 commented Aug 23, 2023

hey guys, i think the issue here is here

if ($LocalLicenseInfo) {
Write-PScriboMessage "Discovered License information for $($LicenseInfo.ProductName) at $($ProtectedSiteName)."

if ($RemoteLicenseInfo) {
Write-PScriboMessage "Discovered License information for $($LicenseInfo.ProductName) at $($RecoverySiteName)."

in the Get-ABRSRMLicense.ps1

** i haven't tested yet, but i had the same error and i can't find a reference anywhere else to $licenseInfo

rebelinux added a commit to rebelinux/AsBuiltReport.VMware.SRM that referenced this issue Aug 23, 2023
@rebelinux rebelinux mentioned this issue Aug 23, 2023
7 tasks
@rebelinux rebelinux mentioned this issue Aug 23, 2023
7 tasks
@rebelinux
Copy link
Collaborator

rebelinux commented Aug 23, 2023

Code has been added that possibly fixes this issue. Please upgrade to the latest version of the report.

Update-Module AsBuiltReport.VMware.SRM -Force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants