Good afternoon all, I am trying to automate the changing of an alarm trigger with VCenter 5. Currently when users use 75% or more of the storage on the local HD I get an alarm for "Datastore Disk Usage". I want to change the Warning from 75% to 85% and the Alert from 85% to 90%. I have been using VSphere PowerCLI for many tasks from adding and configuring hosts and their storage, networks, dns, etc... So I understand the basics. I just can't seem to figure out how to do anything other then get the name of the alarm. Any help would be appreciated.
Change Alarm Triggers in VCenter through PowerCLI
vMotion TCP/IP Netstack - gateway
create PowerCLI script - Windows task scheduler
I read some doc about how to run my PowerCLI script to get my reports.
I understood It's necessary to initialize PowerShell environment to load required components and if you want to load all these ones, you have to run the script Initialize-PowerCLIEnvironment.ps1. It's right?
If I open the link, which VMware Power CLI created during installation, it shows:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1
How Can I run my script (test.ps) by the previous line loading all components?
What do you suggest me please?
The ramdisk 'tmp' is full. ASAP
Hello guys,
can anyone help me with script a clean tmp files via PowerCLI.
My host disconnected from VCenter, and i can't connect for SSH.
Scheduled Maintenance Mode with eMail report
Hi,
I was looking at a post from a few months back
I tweaked it a bit to powerdown VM's before placing the host into Maintenance Mode
(couldn't vMotion them as the Hosts in this case are not part of a cluster)
Here's what I've come up with.
This works except the body of the email received is
"*
26"
I was expecting "ServerName OK", this is the content of the $report variable
$hostlist=Get-VMHost ($serverlist)
$sMaint=@{
enable=$true
timeout=60
}
$report=@()
# If Host is in a Cluster, vMotion VM's to other Hosts in the Cluster
<# work in progress #>
# If Host is standalone, powerdown any running VM's
Foreach ($vmhostin$hostlist)
{
foreach ($vmin$vmhost)
{
$v=$vm|Get-VM
if ($v.PowerState-match'PoweredOn' )
{
Shutdown-VMGuest $v-Confirm:$false-ErrorAction SilentlyContinue
}
}
}
# Put Host into Maintenance Mode
Foreach ($serverin$serverlist)
{
$esxcli=Get-EsxCli-VMHost $server-V2
if($esxcli.system.maintenanceMode.set.Invoke($sMaint))
{
$report+="$($server) OK"
}
else
{
$report+="$($server) NOK"
}
}
# Email a report
$sMail=@{
From='Jason.Pierce2@emc.com'
Subject='Scheduled Maintenance Mode'
Body=$report|ConvertTo-Html|Out-String
BodyAsHtml=$true
SmtpServer='mailhub.lss.emc.com'
}
Send-MailMessage@sMail
How do I correct the email body content ?
Refresh Connection State to vcenter after diconnect from ESXi Host
Hey there,
what i try and what i do..
I have a script which will configure some Settings of my ESXi Hosts from the vCenter view and also will create local ESXi User... for this task i connect to the ESXi Host directly..
Soo..what i do ..
----
1. Connect to my vcenter...
2. Start my script...
3. All Setting will be aplied to the first esxi host in the list...
4. Connect to esxi
Connect-VIServer $esx_Host.Name -User $rootpwd.User -Password $rootpwd.Password -wa 0
create a user...
Disconnect-VIServer -Server $esx_Host.Name -Confirm:$false
5. The loop starts again.. and..
Get-VMHost : 29.06.2018 15:30:31 Get-VMHost You are not currently connected to any servers. Please connect first using a Connect cmdlet.
----
I try this on the cli ...
Connect-VIServer <vcenter> (OK)
Connect-VIServer <esxi host> (OK>
Disconnect-VIServer -Server <esxi Host> (Ok)
Get-VMHost
Get-VMHost : 29.06.2018 15:30:31 Get-VMHost You are not currently connected to any servers. Please connect first using a Connect cmdlet.
In Zeile:1 Zeichen:1
+ Get-VMHost
+ ~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Get-VMHost], ViServerConnectionException
+ FullyQualifiedErrorId : Core_BaseCmdlet_NotConnectedError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVMHost
Get-VMHost -Server <vcenter> (works)
Name ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz MemoryUsageGB MemoryTotalGB Version
---- --------------- ---------- ------ ----------- ----------- ------------- ------------- -------
So the connection to the vcenter is still there.. is it possible to recover this connection as default connection?
Greetz
Can PowerCLI work on windows desktop and query directly to ESXI without having the Vsphere and Vcenter installed on desktop?
Any prompt answer will be appreciated!!VMware PowerCLI
Get-Stat Permission to perform this operation was denied.
I can view performance metrics in vsphere web access and pull vm information using get-view but when I try to use get-stat I receive the following error.
Get-Stat Permission to perform this operation was denied. Required privilege 'System.Read' on managed object with id 'Folder-group-d1'.
I am not an admin in this VMSphere environment but I have been told by the admins I do have access. Is anyone able to tell me what permissions/roles could be missing so that I can take them back to the admins and have them test this. I only have access to a set of folders and vm clients. So I will not be able to be set as an admin. This is a corporate environment so that is not possible.
Connect-VIServer Method not found: 'Void VMware.Vim.VimClient.set_UseSystemProxy
I am running powercli script from .net application and this used to work in 6.5.1 but with latest version when i run powercli script from c# c.net i get this error:
Connect-VIServer Method not found: 'Void VMware.Vim.VimClient.set_UseSystemProxy
If i run script from powershell console it works fine, just fail when runing hosted in .net.
Any idea what is wrong or has changed in 10.x?
How can I run a powercli script from CMD ( in Jenkins)
How do I change the default gateway on a VMkernel network adapter?
How do I change the default gateway on a VMkernel network adapter?
I created a VMkernel network adapter using this code:
New-VMHostNetworkAdapter -VMHost $vmHost -PortGroup "vMotion" -VirtualSwitch $virtualSwitch -IP 10.202.5.101 -SubnetMask 255.255.255.0 -VMotionEnabled:$true -Mtu 9000
It was created with the wrong default gateway of 10.202.1.1 rather than the correct default gateway of 10.202.5.1.
How do I set the default gateway to 10.202.5.1?
I can make the changes in the GUI:
But I cannot figure out how to make the change in PowerShell 6, PowerCLI 10.
Any help would be greatly appreciated.
Thanks!
-Chris
how to copy and execute bash script on esxi server
any idea how I can copy a folder with bash scripts to a local DS and execute on the esxi host?
(Get-CisService com.vmware.content.local_library).list() does not work
Hi,
I am using content library items sync. The following codesnippet does not work with line System.Windows.Forms uncommented.. Powershell version is 5.0 and .NET 4.0/4.6.1.
# $groupBoxLog = New-Object System.Windows.Forms.GroupBox
connect-cisserver -server myserver -user user -password password
$contentlibrary = Get-CisService com.vmware.content.local_library
$libraries=$contentlibrary.list()
any idea?
Daniel
plink putty error
c:\scripts\plink.exe : Errors:
At line:1 char:1
+ c:\scripts\plink.exe -pw xxxxx root@esx "/sbin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Errors: :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Invalid operation requested: This ruleset is required and connot be disabled
any idea why i am getting this error? The putty session restarts the services.sh fine but got error
Write-Output "yes" | plink $plink $vmhost root 'xxxxx' '/sbin/services.sh restart'
RDM SCSI LUN
Hi,
Need Your Help !!!
we have a requirement Re-locate the RDM VM's, connected to the MSCS Clusters.
Hence We need the SCSI controller information on connected RDM Disk details with SCSI Controller information and need to map same LUN ( VMDK ) has been adding to existing disk of the passive node.
Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName
PowerCLI - Set/Get-Datastore SIOC "Percentage of peak throughput"
Hello,
Previously to ESXi 6, we have managed our datastores & their SIOC configurations using PowerCLI:
Get-Datastore | Select Name,StorageIOControlEnabled,CongestionThresholdMillisecond
Get-Datastore NAMEOFDATASTORE | Set-Datastore -StorageIOControlEnabled $true -CongestionThresholdMillisecond 40
However, now we want to use "Percentage of peak throughput". We want to apply the new configuration using PowerCLI, but I can't seem to find any documentation to suggest "Set-Datastore" has been improved & new functionality added.
"Get-Help Set-Datastore" doesn't give me any suggestions / ideas either.
I've found something in the VMware documentation below that suggests it's been thought of through an orchestrator API?
Can anyone advise if we can get & set this using PowerCLI?
Thanks
errors when ptching esxi hosts
Not sure why I am getting these errors when patching a hosts using vum cmdlets. ITs remediating just fine but getting these errors
$vmhosts = get-vmhost (get-content "c:\scripts\esxhosts.txt") | sort Name
foreach ($vmhost in $vmhosts) {
get-vmhost -name $vmhost | set-vmhost -state Maintenance -confirm:$false
$baseline = get-baseline -server vc1 -name "base1"
$baseline | attach-baseline -entity $vmhost -confirm:$false
scan-inventory -entity $vmhost
$baseline | remediate-inventory -entity $vmhost -confirm:$flase -erroraction Silentlycontinue
Automate "scheduled tasks"
Hello,
couldn't find any cmdlets for creating scheduled tasks for VMs. Please advise!
Get all objects that a user has permissions to
I'm looking at creating a script to list all objects that a specific user account has access to, this can be any role.
I cant find anything in the PowerCLI documentation that will help here, does anyone have any pointers?
Powercli : current tasks of pools and VMs in Horizon View
Hello,
Is it possible to see the current tasks of poolls and VMs in powercli in Horizon View?
Thank You