Solved

PowerCLI Script used to Collect Host Logs

Posted on 2016-10-24
1
68 Views
1 Endorsement
Last Modified: 2016-10-25
I am attempting to run the following simple PowerCLI script to collect host logs.

code…

Connect-VIServer myviserver
$esx = Get-VMHost myhost
$log = Get-Log -Key “vmkernel” -VMhost $esx
$log.entries > c:\logs.txt


When I run the script an error message is generated.

It reports that the Connect-VIServer command is not recognized as the name of a cmdlet.

Any ideas why this error message in being presented.

Thanks,

Lipotech
1
Comment
Question by:lipotech
1 Comment
 
LVL 119

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE^2) earned 500 total points
ID: 41857571
You've not added the Snapin... or not running VMware vSphere PowerCLI, e.g just running Powershell.

try this at the start of your Script

Add-PSSnapin "VMware.VimAutomation.Core" | Out-Null

Open in new window

0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question