Closed mohammedamirk closed 4 years ago
Can you expand a bit more on what you mean by
... unable to connect and fetch the details of my vCenter server using PowerCLI code.
When i tried to run the vCheck script from the MVC.net code i can generate the HTML output but unable to get the correct output as you can see the output shows (No of Host-1, No of VMs-1). It seems my script is not fetching the VI-Server details
Did you try a run of vCheck.ps1 from a PowerShell prompt? To make sure the settings are correct. Does that produce a report that is correct?
Also, can you check the output of the vCheck script (stdout, stderr and verbose). See Get Powershell command's output when invoked through code
Yes. I tried running the vCheck.ps1 from the Powershell prompt and it is giving me the correct output. However while executing it from MVC code iam not getting the output as expected
Can you attach the output of the script when you run it from MVC?
Here is the output
That is not what I mean. The vCheck.ps1 script produces input to stdout and possible stderr. This appears on the PS console when running directly from a PS session. That output, when running from your code, is what I would like to see.
Hi lucd 1) Attached here is output of the PS console when running directly from a PS session 2) Attached screenshot of the PSSession Html output
Please let me know if this is exactly what your are looking for?
I don't understand why you get the error on the Connect-VIServer cmdlet and still the script is able to produce a result. That could mean that there is an open connection (check with $global:defaultviservers).
But I would really need to see this same output when you run the script from your code, not from a PS console.
$OpenConnection = $global:DefaultVIServers | Where-Object { $_.Name -eq $VIServer } if($OpenConnection.IsConnected) { Write-CustomOut ( "{0}: {1}" -f $pLang.connReuse, $Server ) $VIConnection = $OpenConnection } else { Write-CustomOut ( "{0}: {1}" -f $pLang.connOpen, $Server )
Iam facing this issue while executing from MVC asp.net app.
That is why I would like to see the output from vCheck.ps1 when it runs from your code.
Hi lucd, Iam sharing you the steps recorded while debugging the vcheck scripts from my MVC .net code I would appreciate if you could please check and share ur inputs. MVC .net Integration issue rcd.zip
Hi lucd, Did u get any chance to look into this issue.
I did, but I'm afraid I don't see any obvious cause for what you are seeing. But then again, I'm not a developer.
What I could suggest is to try the same but with a simple PowerCLI script. Just a Connect-VIServer and for example a Get-VM. Then save the output to a CSV file.
See if that runs ok.
If it does, gradually make the script more complex.
Hi Lucd, I resolve the issue. Now the vcheck code is sucessfully integrated with MVC.Net code
Would you mind sharing your solution?
Sure. I figure out that my MVC.Net code is correct and there was some error due to multiple versions of powershell installed. So First I uninstall the powershell versions and reinstall again. It seems some execution policy was missing and self-sign certificates due to which it was not fetch the powerCLI modules. So Install a fresh powerCLI: Step-1: Install-Module -Name VMware.PowerCLI Step-2: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned Step-3: Import-Module VMware.VimAutomation.Core Step-4: Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false Step-5: Set-PowerCLIConfiguration -InvalidCertificateAction ignore -confirm:$false Step-6: Update-Module -Name VMware.PowerCLI Then try running it from my .net code. IT WORKS :)
Hi all, Iam facing an issue while integrating the MVC based asp.net application with the vSphere vCheck script Codebase. While executing the code from my controller in asp.net application iam able to generate the html output successfully from the code but unable to connect and fetch the details of my vCenter server using PowerCLI code.
MVC Controller code: try { TempData["Result"] = ""; // Clean the Result TextBox string ResultBox = string.Empty;
================================================== Ouput:![vcheck output](https://user-images.githubusercontent.com/43793957/76894925-0b873100-68b5-11ea-811e-251a5c931fe8.png)
Iam able to generate the html output successfully from the code but unable to connect and fetch the details of my vCenter server using PowerCLI code. Looking for a possible solution on this.