PowerCLI vCheck 5.38

It has been a little over 3 months since I’ve posted an update to vCheck. I still have some features and bug checks I’d like to add, but figured I’d share the current state. Here are the in-code comments for the new sections:

# Version 5.38- bwuch: bug fix with 'connectionstate' warning
# Version 5.37- bwuch: added SYMC to VCB check for Symantec Backup Exec 2010
# Version 5.36- bwuch: changed snapshot function
# Version 5.35- bwuch: Added section with Powered Off VMs showing the last powered on date/event.
# Version 5.34- bwuch: Added the CBT tracking code provided by rhys on vCheck comments
# Version 5.33- bwuch: Modified Cluster config check to vCheck output format http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/
# Version 5.32- bwuch: Hack to make report look better in Outlook.

For those of you looking for some detail, keep on reading:

5.32 – A single line of code was retro-fitted to make the email report look a little better in Outlook 2007/2010. You can read about that change here: http://enterpriseadmins.org/blog/scripting/minor-update-to-vcheck-5-31-beta-testers-required/

5.33 – I took the really cool looking cluster config check from the following site: http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/ and changed the output so it would appear in vCheck. This is a really cool looking report with solid data, but it doesn’t really look good on clusters with more than 3 or 4 hosts (due to the table resizing). If you want to disable/hide these checks, you need to set the variables on lines 182, 183 and 184 to $false.

5.34 – A user over at Virtu-Al.net posted some code in the comments that allows checking of Change Block Tracking (a backup mechanism based off the vStorage API for Data Protection). That code has been incorporated into this version.

5.35 – A user at Virtu-Al.net posted a request for powered off VMs with the time they were last powered on. The code was already available here http://blogs.vmware.com/vipowershell/2009/10/when-was-the-last-time-that-vm-was-powered-on.html so I incorporated it into vCheck result format.

5.36 – I changed the snapshot checks to make use of some PowerCLI advances; removing some custom functions that Alan had in the original vCheck and possibly improving performance for environments with large numbers of snapshots. The snapshot code is available independently here: http://enterpriseadmins.org/blog/scripting/vsphere-snapshot-report/

5.37 – A user posted a comment to the vCheck 5.31 thread stating that their backup product has snapshots named “SYMC*” that should appear in the VCB Garbage check. Updated code as requested.

5.38 – During some test runs prior to posting I encountered another PowerCLI warning related to changes in the functions in PowerCLI 4.1. I resolved that specific issue in this version.

You can download the updated version here: vCheck5.38.ps1

Please feel free to leave a comment with any suggestions or problems you may encounter.

This entry was posted in Scripting, Virtualization. Bookmark the permalink.

13 Responses to PowerCLI vCheck 5.38

  1. I’ve just found 2 bugs (at least) that exist in the 5.38 version of this script.

    Bug #1) in the section that starts “if ($checkClusterDataStores)” the $datastores variable was re-used which causes issues with future use of the variable – like in the over allocation check.

    Bug #2) in the section starting “$guestDownTime = @()” the $vm variable was re-used. This doesn’t cause issues like bug #1 (because the use of $VM is similar in each script), but it isn’t really needed. Performance could be improved without the line of code.

    As soon as I get a chance I’ll update the script to correct these two bugs.

  2. johan says:

    Is it possible to schedule this nice script on a windows 2008 server?
    Cant find any working info here or on VirtuAl site.
    Possible?

    Regards

    Johan

  3. Pingback: EnterpriseAdmins.org » Blog Archive » PowerCLI vCheck 5.40

  4. @Johan, this is how I run my scheduled task from Windows 2008:

    On the ‘Actions’ tab select the action ‘Start a program’

    The Program/script is (no quotes):
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

    The ‘Add arguments (optional)’ box contains:
    -psconsolefile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -file C:\Scripts\vCheck5.ps1 vcenter.testing.local

    The ‘Start in’ box is blank.

    Please let me know if this works for you — if so I’ll dedicate a new post to configuring the scheduled task.

    Thanks,
    @bwuch

  5. johan says:

    Hi Brian!

    Cant get it to work 🙁
    Trying to schedule the task on Windows 2008 R2

    Program/script :
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

    Add arguments (optional):
    -psconsolefile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -file c:\scripts\vCheck-5.38-mail.ps1 myvCenter.local

    log :
    Task Scheduler successfully completed task “\Weekly HealtCheck of myvcenter.local” , instance “{637c1edf-fc92-4bb1-94fc-2d2d5384038f}” , action “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe” with return code 1.

    I can run the script interactive throw powercli window without any problems…

    Regards
    Johan

  6. johan says:

    Hi again,

    I see now that i cant run the script interactive on my windows 2008 r2 box.

    File C:\scripts\vCheck5.40.ps1 cannot be loaded. The file C:\scripts\vCheck5.40
    .ps1 is not digitally signed. The script will not execute on the system. Please
    see “get-help about_signing” for more details..
    At line:1 char:17
    + .\vCheck5.40.ps1 <<<< myvcenter

    I can run vCheck 5.0 interactive from my windows 2008 box.
    I can run all the script from my windows 7 box….

    /powershell noob

  7. @johan

    If you right click on the file you downloaded and select properties, there may be a Security warning at the bottom of the general tab. It would state something to the effect ‘this file came from another computer and might be blocked to help protect this computer.’ You can unblock the file by clicking the button to the right of the warning message.

    If that doesn’t fix the error you might try changing your Powershell execution policy. You could do this by running “Set-ExecutionPolicy Unrestricted” from a Powershell window.

    Please let me know if either option helps!

    Thanks,
    @bwuch

  8. johan says:

    Hi Brian,
    Thanks for your help!

    Been on vacation for a couple of days , thats why i havent answer you until now.
    I can now run all vcheck scripts interactive from my windows 2008 r2 box.

    But i still have problems to be able to schedule the vCheck…
    Mi lines :
    ——
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    ——
    -psconsolefile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″ -file c:\scripts\vCheck5.40.ps1 myvcenter.mydomain.local

    When i rightclick the job and chose “run now” i can see that the state is running for a couple of secs and then it get backs to ready.
    Last run result = (0xFFC0000)

    Feels like som security thing on windows 2008 r2 servers!?
    I run this job with under a domain admin account.

    You are able to get it to work on an windows 2008 r2?

    BR
    Johan

  9. Johan, I was able to run the vCheck from a 2008R2 server this evening. Additionally, I was able to recreate the 0xFFFC0000 error (by accident) and was able to get past it. After getting the 0xFFFC0000 error from a scheduled task, I ran a command window using the same account I was trying to use for my scheduled task. Then I tried to execute this command:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -file “D:\Program Files\Scripts\scheduledTask.ps1 myvcenter.test.local

    As you can see, this differs from my previous example in two ways. 1.) The path to my script is in the D:\Program Files directory (which contains a space) and 2.) I’ve added a quote before the D:\ path since the full path has a space in it, but forgot the trailing quote after the .ps1. The error I got when trying to execute this command from the cmd window was:
    Processing -File ‘D:\Program Files\Scripts\scheduledTask.ps1 myvcenter.test.local’ failed because the file does not have a ‘.ps1’ extension. Specify a valid PowerShell script file name, and then try again.

    I re-ran the command with the trailing quote and everything appeared to start working. So I then modified my scheduled task to also have the trailing quote and now I’m in business on 2008R2!

    Could you try running the following from a command window (as the scheduled task account user):
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -file “C:\Scripts\vCheck5.40.ps1” myvcenter.test.local

    Please report back any errors that might appear on screen and we’ll try to work through them.

    Thanks,
    Brian

  10. johan says:

    Hi Brian,

    When i try to run the command in CMD i get this error.

    C:\>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile “C:
    \Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -file
    “C:\Scripts\vCheck5.40.ps1” vcenter01.mydomain.local
    Windows PowerShell console file “”C:\Program” extension is not psc1. Windows Pow
    erShell console file extension must be psc1.

    Works great if i run the command in PowerCli console.
    But still im not able to get it to run as a scheduled task 🙁

    Regards

    Johan

  11. @Johan, sorry for the delay. I must have missed the email notification of this comment.

    I’ve seen a very similar error message to the one you mention about the PSC1 file extension. When I had the error it was because I was missing one of the quotes. What I’m afraid is that the comment section of the blog is messing with the quote character. Try and copy the section below and then go back and remove all the double quote characters and replace them with the normal double quote (just to verify this isn’t a formatting error).

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -file "C:\Scripts\vCheck5.40.ps1" myvcenter.test.local
    

    (I included pre-formatted test tags above…if the comment section parses HTML you shouldn’t see them. If you do see them you don’t need to include them in the copy/paste.)

    Thanks,
    Brian

  12. Mark says:

    Guys question.. Running this report and I understand every field except the capacity info field . What does the following actually mean.

    The following gives brief capacity information for each cluster based on average CPU/Mem usage and counting for HA failover requirements

    I am getting the following numbers and not sure exactly what is it telling me.

    When it tells me 59 estimated Num VM left (CPU) and 39 Estimated Num VM Left (MEM)

  13. What i don’t understood is if truth be told how
    you are not actually a lot more neatly-preferred than you
    may be right now. You are so intelligent. You realize thus significantly in relation to this topic, made me in my view believe it from so many
    varied angles. Its like women and men are not involved unless it’s
    one thing to accomplish with Lady gaga! Your personal stuffs nice.

    At all times deal with it up!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.