所以首先我仍然没有得到普通 Powershell 和带有 ESXCLI 的 PowerCLI 之间的确切区别。我真的试着理解它是如何工作的等等。所以是的,我做了一些研究。现在我的问题
我正在尝试做的主要任务:vCenter 通过 POWERCLI 执行一个 .ps1 脚本,它已经可以按应有的方式重新启动 vm。我的任务是为所有虚拟机制作弹出窗口通知。
通知本身如下所示:
Add-Type -AssemblyName System.Windows.Forms
$global:balmsg = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -id $pid).Path
$balmsg.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning
$balmsg.BalloonTipText = "Die VM startet in 30 Sekunden neu"
$balmsg.BalloonTipTitle = "Achtung!"
$balmsg.Visible = $true
$balmsg.ShowBalloonTip(1)
我通过网上找到的指南安装了 ESXCLI,我只需要重新启动 .ini 即可安装它。然后我在我的代码中尝试了一些东西,但我所做的一切都会给我一个基于语法的错误......
$esxcli = Get-EsxCli -VMHost vCenter -V2
esxcli storage nfs list
Invoke-Command -ComputerName $vm -Credential xxx.local\$vm -ScriptBlock { Get-Culture }
$esxcli.shell.cmd("Invoke-Command -ComputerName VM-xxx -ScriptBlock { Get-Culture }", $null, $null, $null, $null)
$esxcli.shell.cmd("Invoke-Command -ComputerName $vm -Credential xxx.local\$vm -ScriptBlock { Get-Culture }")
Invoke-Command -ComputerName VM-xxx -ScriptBlock {
Add-Type -AssemblyName System.Windows.Forms
$global:balmsg = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -id $pid).Path
$balmsg.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning
$balmsg.BalloonTipText = "Die VM startet in 30 Sekunden neu"
$balmsg.BalloonTipTitle = "Achtung!"
$balmsg.Visible = $true
$balmsg.ShowBalloonTip(1)
}
这就是把所有东西放在一起,看看我尝试的任何东西是否有效。但遗憾的是没有。据我所知,我得到的错误都是基于语法的,所以这就是为什么我认为我不太了解 ESXCLI 是如何工作的。
如果你们能帮助我,即使只是一个关于我想要完成的特定任务的好教程的链接,那就太好了。