Hi Guys,
I'm just new in scripting and I need a help.
It's any change to write script that will calculate for each virtual machine a maximum value MemoryMB and NumCpu from the last week or month? I mean counting every hour and check the highest value of the day and the week or even a month. Is it even possible?
I would avoid solutions with a simple "get-vm | select", which will run every hour throughout the entire period of time and then manually search for the highest value.
Can someone help me with this?
I'm not sure I get the question correctly ?
Do you
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, but the important thing is that I have to submit report with the highest CPU and RAM settings for each VM / per day, week or last month.
I do not want to run this little script:
get-vm | select VMname, MemoryMB, NumCpu
by each hour (24 per day) to a csv file and look for the values manually.
Afaik, these values are not kept historically.
But, you could look at the events that are created when the config of a VM is changed.
See my Events – Part 3 : Auditing VM device changes post for more details on this.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thx. I have one last question.
I run the script using:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noexit -command c:\scripts\get-vm.ps1
then in the script I log on to the vCenter
Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer -Server 192.168.30.156 -Protocol https -User Administrator -Password XXXX
get-vm | select Name, VMHost, MemoryMB, NumCpu, UsedSpaceGB, ProvisionedSpaceGB | Export-Csv "c:\$((Get-Date).ToString('yyyy-dd-MM_HH-mm-ss')).csv" -noTypeInformation
but I have a login error:
Connect-VIServer : 2014-04-09 09:59:53 Connect-VIServer Cannot comple
te login due to an incorrect user name or password.
At line:1 char:1
+ Connect-VIServer -Server 192.168.30.156 -Protocol https -User Administrator -
Pas ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : NotSpecified: (:) [Connect-VIServer], InvalidLog
in
+ FullyQualifiedErrorId : Client20_ConnectivityServiceImpl_Reconnect_Excep
tion,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer
What can I do?
The message seems to indicate the user/password is incorrect.
Can you logon to the vSphere Client with that user/password ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, of course.
Also when I try to just "connect-viserver" it works:
That means that the connection will be done with your current credentials, and those work.
Do you happen to have some "special" characters in your password ?
Try placing the password between single quotes.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Probably '$' disturbed. Single quotes have helped.
I owe you! THX.