Automation

 View Only
  • 1.  vcheck

    Posted Nov 18, 2010 10:41 AM

    Hi All,

    Couple of queries on which we need your suggestions:

    1. Need to modify the following code under this script: "# -


    VM Disk Space - Less than x MB -


    ".

    We have certain partitions (say for example /boot 100MB) which does not require this check. Can we exclude those partitons from the report but continue the check on rest of the partitions.

    2. While running the code below the section:

    1. ---- Virtual Center Details ----

    #If ($ShowVCDetails){

    1. Write-CustomOut "..Checking VC Services"

    The script always prompts for username and password which may pose a problem if the script is scheduled. Though I can see it generates a credential file in the beginning, somehow i feel its not reading this file. Can we eliminate the prompt for login ?

    Thank you for suggestions.

    A



  • 2.  RE: vcheck

    Posted Nov 18, 2010 11:00 AM

    I assume you are referring to Alan's vCheck script ?

    Wouldn't it be better to raise your questions on Alan's site.

    He is quite responsive over there :smileywink:

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 3.  RE: vcheck

    Posted Nov 18, 2010 11:10 AM

    Yes I am referring to the same script. Alas! I dint get any reply to one of my last query. And even while checking the blog I just saw another member who has almost the same query (credentials pop up while scheduling the script).

    I understand your involvement in various activities and would appreciate any help. I am trying to learn as fast as I can :smileyblush:

    Thanks,

    A



  • 4.  RE: vcheck
    Best Answer

    Posted Nov 18, 2010 01:04 PM

    Sorry to hear that.

    For your first question, you could adapt the part about "VM Disk Space - Less than x MB" like this

    		# ---- VM Disk Space - Less than x MB ----
    		$doNotReport = @("boot","E:\") # Added
    		
    		If ($ShowGuestDisk){
    			Write-CustomOut "..Checking for Guests with less than $MBFree MB"
    			$MyCollection = @()
    			$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq "poweredOn" -And ($_.Guest.toolsStatus -ne "toolsNotInstalled" -And $_.Guest.ToolsStatus -ne "toolsNotRunning")}
    			$SortedVMs = $AllVMs | Select *, @{N="NumDisks";E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks
    			ForEach ($VMdsk in $SortedVMs){
    				$Details = New-object PSObject
    				$DiskNum = 0
    				Foreach ($disk in $VMdsk.Guest.Disk){
    					if (([math]::Round($disk.Capacity/ 1MB)) -lt $MBFree -and $doNotReport -notcontains $disk.DiskPath){		# Changed
    						$Details | Add-Member -Name Name -Value $VMdsk.name -Membertype NoteProperty
    						$Details | Add-Member -Name "Disk$($DiskNum)path" -MemberType NoteProperty -Value $Disk.DiskPath
    						$Details | Add-Member -Name "Disk$($DiskNum)Capacity(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.Capacity/ 1MB))
    						$Details | Add-Member -Name "Disk$($DiskNum)FreeSpace(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB))
    						$DiskNum++
    						$MyCollection += $Details
    						}
    				}
    				
    			}
    			If (($MyCollection | Measure-Object).count -gt 0) {
    				$MyReport += Get-CustomHeader "VMs with less than $MBFree MB : $($MyCollection.count)" "The following guests have less than $MBFree MB Free, if a guest disk fills up it may cause issues with the guest Operating System"
    					$MyReport += Get-HTMLTable $MyCollection
    				$MyReport += Get-CustomHeaderClose	
    			}
    		}
    

    All the disk paths listed in $doNotReport will not be included in the report.

    Can you check if the script created the credentials file (default location .\MyCred.crd) during the first run ?

    On the next run, the script should be picking up the credentials from that file (provided it exists).

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 5.  RE: vcheck

    Posted Nov 19, 2010 05:17 AM

    Hi Luc,

    Manipulated the script as per your suggestion but still seeing the same partitions. Please refer to the attachment.

    As for the pop up thing, just missed from my mind that I recently changed my password. My bad :smileyblush:

    Thanks for your help!



  • 6.  RE: vcheck

    Posted Nov 19, 2010 05:26 AM

    Hi Luc,

    I manipulated the script as suggested but still it shows the same pattern. I am unable to attach the image but it shows something like:

    VMs with less than 1000MB : 69

    The following guests have less than 1000MB free, if a guest disk fill up it may cause issue with the operating system.

    Name Disk0path Disk0Capacity(MB) Disk0FreeSpace(MB)

    xyz /boot 99 80

    abc /boot 99 85

    As for the credentials pop-up, just missed from my mind that I recently changed the password. My bad :smileyblush:

    Thanks



  • 7.  RE: vcheck

    Posted Nov 19, 2010 06:26 AM

    Did you specify "/boot" in the array ? With the slash ?

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 8.  RE: vcheck

    Posted Nov 19, 2010 07:18 AM

    How dumb of me to miss it. Works exactly as intended. Thank you once again for all your efforts and time. Wish could have given you a hundred for all your help. You are my scripting Guru..Thanks!! :smileyblush:



  • 9.  RE: vcheck

    Posted Nov 22, 2010 04:45 AM

    Thanks for sharing your script here Luc !

    Kind Regards,

    AWT



  • 10.  RE: vcheck

    Posted Jul 03, 2015 07:17 PM

    Is this still applicable today?

    I tried it with the latest .ps1 from VIrtu-al and it is not working.

    Here it is - can someone let me know what I have to add to remove a particular drive letter please???

    # Start of Settings
    # VM Disk space left, set the amount you would like to report on MBFree
    $MBFree = 1024
    # VM Disk space left, set the amount you would like to report on MBDiskMinSize
    $MBDiskMinSize = 1024
    # End of Settings

    $MyCollection = @()
    $AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq "poweredOn" -And ($_.Guest.toolsStatus -ne "toolsNotInstalled" -And $_.Guest.ToolsStatus -ne "toolsNotRunning")}
    $SortedVMs = $AllVMs | Select *, @{N="NumDisks";E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks
    ForEach ($VMdsk in $SortedVMs){
    $Details = New-object PSObject
    $DiskNum = 0
    $Details | Add-Member -Name Name -Value $VMdsk.name -Membertype NoteProperty
    Foreach ($disk in $VMdsk.Guest.Disk){
      if ((([math]::Round($disk.Capacity / 1MB)) -gt $MBDiskMinSize) -and (([math]::Round($disk.FreeSpace / 1MB)) -lt $MBFree)){
       $Details | Add-Member -Name "Disk$($DiskNum)path" -MemberType NoteProperty -Value $Disk.DiskPath
       $Details | Add-Member -Name "Disk$($DiskNum)Capacity(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.Capacity/ 1MB))
       $Details | Add-Member -Name "Disk$($DiskNum)FreeSpace(MB)" -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB))
       $DiskNum++
       }
    }
    if ($DiskNum -gt 0){
      $MyCollection += $Details
    }
    }
    $MyCollection

    $Title = "Guests with less than $MBFree MB"
    $Header = "VMs with less than $MBFree MB : $(@($MyCollection).count)"
    $Comments = "The following guests have less than $MBFree MB Free, if a guest disk fills up it may cause issues with the guest Operating System"
    $Display = "Table"
    $Author = "Alan Renouf"
    $PluginVersion = 1.1
    $PluginCategory = "vSphere"



  • 11.  RE: vcheck

    Posted Jul 07, 2015 01:59 PM

    Did you find the solution?

    I also am looking at achieving this as well.