Solved

When creating and Excel file why always get Theaction can't be completed..........open in Windows PowerShell

Posted on 2013-06-18
11
265 Views
Last Modified: 2013-06-19
I have a script that creates an excel file, but if i want to delete the file manually i cannot because is opened by windows powershell. I have to exit of the Powershell then I can delete the file.
thanks,
0
Comment
Question by:namerg
  • 7
  • 4
11 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
I guess the excel is not closed properly.. If you can post the code then it will help.. :-)

Here is a sample code to create excel file..
$xl=New-Object -ComObject "Excel.Application" 
$xl.Visible = $false
$wb=$xl.Workbooks.Add()
$ws=$wb.ActiveSheet
$cells=$ws.Cells
$cells.item(1,1)="TestReport"
$cells.item(2,1)="TestData"
$wb.SaveAs("C:\temp\Test.xlsx")
$xl.Quit()

Open in new window

0
 

Author Comment

by:namerg
Comment Utility
Hmm, I am closing but I am not Quiting...let me try..
0
 

Author Comment

by:namerg
Comment Utility
You got it. The key was $xl.Quit()
0
 

Author Comment

by:namerg
Comment Utility
Hmm, too quick....still not working the EXCEL process still running....
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
When I test, I am able to delete the file even if the excel process is running.. Can you post your code so I can test and see what is wrong...
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:namerg
Comment Utility
Damnn... I do not know what I did :(
 Now I am getting Unable to index into an object of type System.DateTime.
At C:\scripts\VMware\HealthCheck_vCenter2_xls.ps1:292 char:51
+         $Sheet.Cells.Item($intRow,$intColumn) = $array2[ <<<< $i]
    + CategoryInfo          : InvalidOperation: (0:Int32) [], RuntimeException
    + FullyQualifiedErrorId : CannotIndex
Yes, I will post the code. But, has powercli, will not matter ?
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
It's ok..
0
 

Author Comment

by:namerg
Comment Utility
Here it is....

####################################
# VMware VirtualCenter server name #
####################################
$vcserver="COMPANYvcenter2.COMPANYcolo.pvt"

##################
# Add VI-toolkit #
##################
#Add-PSsnapin VMware.VimAutomation.Core
#Initialize-VIToolkitEnvironment.ps1
connect-VIServer $vcserver

#############
# Variables #
#############
$vcversion = get-view serviceinstance
$snap = get-vm | get-snapshot
$date=get-date

#Creating an Excel Object
[reflection.assembly]::loadWithPartialname("Microsoft.Office.Interop.Excel") | out-Null
$Excel = New-Object -Com Excel.Application
$Excel.visible = $False
$Excel = $Excel.Workbooks.Add()

#############################
# Add Text to the EXCEL file #
#############################

#Configuring 1st sheet of the Excel workbook
$Sheet = $Excel.Worksheets.Item(1)
$Sheet.Name = "VMware Health COMPANYvCenter2"
$Sheet.Cells.Item(1,1) = "VMware Health COMPANYvCenter2"
$Sheet.Cells.Item(2,1) = "Date and time"
$Sheet.Cells.Item(3,1) = $date
$Sheet.activate()

$Sheet.application.activewindow.splitrow = 1
$Sheet.application.activewindow.freezepanes = $true

$WorkBook = $Sheet.UsedRange
#$WorkBook.Interior.ColorIndex = 11
#$WorkBook.Font.ColorIndex = 19
$WorkBook.Font.Bold = $True

#######################
# VMware ESX hardware #
#######################
Write-Host "VMware ESX hardware"
$array0 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty Vendor
$array1 =  Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty Model
$array2 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty MemorySize
$array3 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty CpuModel
$array4 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty CpuMhz
$array5 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty NumCpuCores
$array6 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty NumCpuThreads
$array7 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty NumNics
$array8 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object -ExpandProperty NumHBAs

$Sheet.Cells.Item(5,1).font.bold=$true
$Sheet.Cells.Item(5,1) = "VMware ESX server Hardware configuration" 
$Sheet.Cells.Item(6,1).font.bold=$true
$Sheet.Cells.Item(6,1) = "Vendor"
$Sheet.Cells.Item(6,2).font.bold=$true
$Sheet.Cells.Item(6,2) = "Model"
$Sheet.Cells.Item(6,3).font.bold=$true
$Sheet.Cells.Item(6,3) = "Memory Size (GB)"
$Sheet.Cells.Item(6,4).font.bold=$true
$Sheet.Cells.Item(6,4) = "CPU Model"
$Sheet.Cells.Item(6,5).font.bold=$true
$Sheet.Cells.Item(6,5) = "CPU Mhz"
$Sheet.Cells.Item(6,6).font.bold=$true
$Sheet.Cells.Item(6,6) = "CPU Cores"
$Sheet.Cells.Item(6,7).font.bold=$true
$Sheet.Cells.Item(6,7) = "CPU Threads"
$Sheet.Cells.Item(6,8).font.bold=$true
$Sheet.Cells.Item(6,8) = "Num Nics"
$Sheet.Cells.Item(6,9).font.bold=$true
$Sheet.Cells.Item(6,9) = "Num HBAs"

$i = 0
$intRow = 7
$intColumn = 1
$intHwColMax = 9
$xlCenter = -4108
$Rounding = 0

Do {
	#Row 7, Column 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array1[$i]
	$intColumn = $intColumn + 1
	$Rounding = [math]::round((($array2[$i] / "1048576") / "1024"),2)
	$Sheet.Cells.Item($intRow,$intColumn) = $Rounding
	$Sheet.Cells.HorizontalAlignment = $xlCenter
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array3[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array4[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array5[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array6[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array7[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array8[$i]
				
	$i ++
	$intRow ++
	$intColumn = 1
} Until ( $array0[$i] -eq $null )


#######################
# VMware ESX versions #
#######################
#Write-Host "VMware ESX Versions"
$array0 = @()
$array1 = @()
$array2 = @()

$array0 = Get-VMHost | Select Name | Select-object -ExpandProperty Name
$array1 = get-vmhost | Select Version | Select-object -ExpandProperty Version
$array2 = get-vmhost | Select Build | Select-object -ExpandProperty Build

$i = 0
#$intRow equals 17
$intRow = $intRow + 2
$intColumn = 1
$intHwColMax = 9

#$intRow equals 20
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "VMware ESX server versions and builds" 
$intRow = $intRow + 1
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "HOST Name"
$Sheet.Cells.Item($intRow,2).font.bold=$true
$Sheet.Cells.Item($intRow,2) = "Version"
$Sheet.Cells.Item($intRow,3).font.bold=$true
$Sheet.Cells.Item($intRow,3) = "Build"
$intRow = $intRow + 1

Do {
	#Row 14, Column 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array1[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array2[$i]
	$intColumn = $intColumn + 1
					
	$i ++
	$intRow ++
	$intColumn = 1
} Until ( $array0[$i] -eq $null )

######################
# VMware VC version  #
######################
#Write-Host "VMware VC Version"
$array0 = @()
$array1 = @()
$array2 = @()

$array0 = @($DefaultVIServers | Select-Object -ExpandProperty Name)
$array1 = @($DefaultVIServers | Select-Object -ExpandProperty Version)
$array2 = @($DefaultVIServers | Select-Object -ExpandProperty Build)

$i = 0
#$intRow equals 32
$intRow = $intRow + 2
$intColumn = 1
$intHwColMax = 9

#$intRow equals 35
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "VMware VirtualCenter version" 
$intRow = $intRow + 1
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "vCenter Name"
$Sheet.Cells.Item($intRow,2).font.bold=$true
$Sheet.Cells.Item($intRow,2) = "Version"
$Sheet.Cells.Item($intRow,3).font.bold=$true
$Sheet.Cells.Item($intRow,3) = "Build"
$intRow = $intRow + 1

Do {
	#Row 21, Column 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array1[$i]
	$intColumn = $intColumn + 1
	$Sheet.Cells.Item($intRow,$intColumn) = $array2[$i]
	$intColumn = $intColumn + 1
					
	$i ++
	$intRow ++
	$intColumn = 1
} Until ( $array0[$i] -eq $null )


#############
# Snapshots # 
#############
#Write-Host "VMware Snapshots"
$array0 = @()
$array1 = @()
$array2 = @()
$array3 = @()

$array0 = Get-VM | get-snapshot | %{$_.VM.Name}
$array1 = Get-VM | get-snapshot | select-object -expandproperty Name
$array2 = Get-VM | get-snapshot | select-object -expandproperty Created 
$array3 = Get-VM | get-snapshot | select-object -expandproperty Description

$i = 0
#$intRow equals 37
$intRow = $intRow + 2
$intColumn = 1
$intHwColMax = 9

#$intRow equals 40
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "Snaphots Active" 
$intRow = $intRow + 1
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "VM Name"
$Sheet.Cells.Item($intRow,2).font.bold=$true
$Sheet.Cells.Item($intRow,2) = "Name"
$Sheet.Cells.Item($intRow,3).font.bold=$true
$Sheet.Cells.Item($intRow,3) = "Created"
$Sheet.Cells.Item($intRow,4).font.bold=$true
$Sheet.Cells.Item($intRow,4) = "Description"
$intRow = $intRow + 1

If ($array0 -ne $null) {
	Do {
		#Row 26,1
		$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
		$intColumn = $intColumn + 1
		$Sheet.Cells.Item($intRow,$intColumn) = $array1[$i]
		$intColumn = $intColumn + 1
		$Sheet.Cells.Item($intRow,$intColumn) = $array2[$i]
		$intColumn = $intColumn + 1
		$Sheet.Cells.Item($intRow,$intColumn) = $array3[$i]
		$intColumn = $intColumn + 1
					
		$i ++
		$intRow ++
		$intColumn = 1
	} Until ( $array0[$i] -eq $null )
}
Else 
	{
		$Sheet.Cells.Item($intRow,$intColumn) = "No Snapshots"
	}

#################################
# VMware CDROM connected to VMs # 
#################################
#Write-Host "VMware CDRoms Mounted"
$array0 = @()
$array1 = @()
$array2 = @()

$array0 =@(Get-VM | where { $_ | Get-CDdrive | where { $_.ConnectionState.Connected -eq "true" } } | Select-object -ExpandProperty Name)

$i = 0
#$intRow equals 48
$intRow = $intRow + 2
$intColumn = 1

$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "CDROMs connected" 
$intRow = $intRow + 1
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "VM Name"
$intRow = $intRow + 1
Do {
	#52,1
	$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
	$intColumn = $intColumn + 1
					
	$i ++
	$intRow ++
	$intColumn = 1
} Until ( $array0[$i] -eq $null )


#########################
# Datastore information #
#########################
#Write-Host "Datastore Information"
$array0 = @()
$array1 = @()
$array2 = @()

$array0 = Get-Datastore | Select-Object -ExpandProperty Name
$array1 = Get-Datastore | Select-Object -ExpandProperty FreeSpaceGB
$array2 = Get-Datastore | Select-Object -ExpandProperty CapacityGB


$i = 0
$Percent = "%"
$String0 = ""

#$intRow equals 50
$intRow = $intRow + 2
$intColumn = 1

$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "Datastore Space Available" 
$intRow = $intRow + 1
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "Datastore"
$Sheet.Cells.Item($intRow,2).font.bold=$true
$Sheet.Cells.Item($intRow,2) = "UsedGB"
$Sheet.Cells.Item($intRow,3).font.bold=$true
$Sheet.Cells.Item($intRow,3) = "Free GB"
$Sheet.Cells.Item($intRow,4).font.bold=$true
$Sheet.Cells.Item($intRow,4) = "Perc Free"
$intRow = $intRow + 1

Do {
	#52,1
	$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
	$intColumn = $intColumn + 1
	
	$UsedSpace = [math]::round(($array2[$i] - $array1[$i]),2)
	$Sheet.Cells.Item($intRow,$intColumn) = $UsedSpace
	$intColumn = $intColumn + 1
	
	$FreeSpace = [math]::round($array1[$i],2)
	$Sheet.Cells.Item($intRow,$intColumn) = $FreeSpace
	$intColumn = $intColumn + 1
	
	$PercFree = [math]::Round((100 * $array1[$i] / $array2[$i]),0)
	$String0 = "$PercFree$Percent"
	$Sheet.Cells.Item($intRow,$intColumn) = $String0
	$intColumn = $intColumn + 1
					
	$i ++
	$intRow ++
	$intColumn = 1
} Until ( $array0[$i] -eq $null )

$array0 = @()
$array1 = @()
$array2 = @()

#####################
# VMs per Datastore #
#####################
#Write-Host "VMs per Datastore"
$array0 = @()
$array0 =  Get-Datacenter | Get-VM | %{$vm = $_ ; Get-Datastore -VM $vm | %{$vm.Name + "--" + $_.Name} }

$i = 0
$flag = 0
$intRow = $intRow + 2
$intColumn = 1

#$intRow equals 87
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "VMs per Datastore (VM--Datastore)" 
$intRow = $intRow + 1

Do {
	#88,1
	$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
	$i ++
	$intRow ++
} Until ( $array0[$i] -eq $null )

##################
# VM information #
##################
#Write-Host "VM information"
$array0 = @()
$array1 = @()
$array3 = @()
$array4 = @()
$array5 = @()
$array6 = @()
$array7 = @()
$array8 = @()
$array9 = @()
$array10 = @()
$array11 = @()

$array0 = Get-VM | Get-View | ForEach-Object { $_.Name }
$array1 = Get-VM | Get-View | ForEach-Object { $_.Guest.Hostname }
$array2 = Get-VM | Get-View | ForEach-Object { $_.Guest.ipAddress }
$array3 = Get-VM | Get-View | ForEach-Object { $_.Guest.Net } | select Network
$array4 = Get-VM | Get-View | ForEach-Object { $_.summary.runtime.powerState }
$array5 = Get-VM | Get-View | ForEach-Object { $_.summary.config.numcpu }
$array6 = Get-VM | Get-View | ForEach-Object { $_.summary.config.memorysizemb }
$array7 = Get-VM | Get-View | ForEach-Object { $_.summary.quickStats.guestMemoryUsage }
$array8 = Get-VM | Get-View | ForEach-Object { $_.summary.config.numEthernetCards }
$array9 = Get-VM | Get-View | ForEach-Object { $_.guest.toolsstatus }
$array10 = Get-VM | Get-View | ForEach-Object { $_.config.tools.toolsversion }
$array11 = Get-VM | Get-View | ForEach-Object { $_.Guest.GuestFullName }

$i = 0
$intRow = $intRow + 2
$intColumn = 1

$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "Virtual Machine information" 
$intRow = $intRow + 1
$Sheet.Cells.Item($intRow,1).font.bold=$true
$Sheet.Cells.Item($intRow,1) = "VM Name"
$Sheet.Cells.Item($intRow,2).font.bold=$true
$Sheet.Cells.Item($intRow,2) = "Hostname"
$Sheet.Cells.Item($intRow,3).font.bold=$true
$Sheet.Cells.Item($intRow,3) = "IP Address"
$Sheet.Cells.Item($intRow,4).font.bold=$true
$Sheet.Cells.Item($intRow,4) = "Network Name"
$Sheet.Cells.Item($intRow,5).font.bold=$true
$Sheet.Cells.Item($intRow,5) = "Power State"
$Sheet.Cells.Item($intRow,6).font.bold=$true
$Sheet.Cells.Item($intRow,6) = "Num CPU"
$Sheet.Cells.Item($intRow,7).font.bold=$true
$Sheet.Cells.Item($intRow,7) = "Mem Size (GB)"
$Sheet.Cells.Item($intRow,8).font.bold=$true
$Sheet.Cells.Item($intRow,8) = "Guest Mem Usage"
$Sheet.Cells.Item($intRow,9).font.bold=$true
$Sheet.Cells.Item($intRow,9) = "Num Ethernet Cards"
$Sheet.Cells.Item($intRow,10).font.bold=$true
$Sheet.Cells.Item($intRow,10) = "Tools Status"
$Sheet.Cells.Item($intRow,11).font.bold=$true
$Sheet.Cells.Item($intRow,11) = "Tools Version"
$Sheet.Cells.Item($intRow,12).font.bold=$true
$Sheet.Cells.Item($intRow,12) = "OS Version"
$intRow = $intRow + 1


Do {
	#88,1
	$Sheet.Cells.Item($intRow,$intColumn) = $array0[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array1[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array2[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array3[$i].Network
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array4[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array5[$i]
	$intColumn = $intColumn + 1
	
	$Rounding = [math]::round(($array6[$i] / "1024"),2)
	$Sheet.Cells.Item($intRow,$intColumn) = $Rounding
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array7[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array8[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array9[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array10[$i]
	$intColumn = $intColumn + 1
	
	$Sheet.Cells.Item($intRow,$intColumn) = $array11[$i]
	$intColumn = $intColumn + 1
	
	$i ++
	$intRow ++
	$intColumn = 1
} Until ( $array0[$i] -eq $null )


##############################
# Disconnect session from VC #
##############################

disconnect-viserver -confirm:$false
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("B1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("C1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("D1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("E1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("F1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("G1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("H1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("I1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("J1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("K1")
$WorkBook.EntireColumn.AutoFit()

$WorkBook = $Sheet.Range("L1")
$WorkBook.EntireColumn.AutoFit()

$Excel.SaveAs("c:\scripts\vmware\HealthCheckCOMPANYvCenter2.xlsx")
#$WorkBook.SaveAs("c:\scripts\vmware\HealthCheckCOMPANYvCenter.xlsx")
$Excel.Close()
#$Excel.Quit()
Start-Sleep 15
######################
# E-mail HTML output #
######################
# Mail variables #
$enablemail="yes"
$emailattachment = "C:\scripts\VMware\HealthCheckCOMPANYvCenter2.xlsx"
$smtpServer = "ux3.COMPANYcolo.pvt" 
$mailfrom = "VMware Healtcheck <VMWareTech@COMPANYcolo.pvt>"
#$mailto = "COMPANY-NetworkGroup@COMPANYcolo.org"
$mailto = "german.rosero@COMPANYcolo.org"

if ($enablemail -match "yes") 
{ 
	$msg = new-object Net.Mail.MailMessage
	$att1 = new-object Net.Mail.Attachment($emailattachment)
	$smtp = new-object Net.Mail.SmtpClient($smtpServer) 
	$msg.From = $mailfrom
	$msg.To.Add($mailto) 
	$msg.Subject = "VMware Health COMPANYvCenter2"
	$msg.Body = "VMware HealthCheck COMPANYvCenter2"
	$msg.Attachments.Add($att1)
	$smtp.Send($msg)
}


##########################
# End Of HealthCheck_COMPANYvCenter_xls.ps1 #
##########################

Open in new window

0
 

Author Comment

by:namerg
Comment Utility
Now, I know why is breaking...there is a snapshot but as a date format, so that is why cannot be converted: Lines 214 - 217
PowerCLI C:\scripts\VMware> Get-VM | get-snapshot | %{$_.VM.Name}
US10-EMC
PowerCLI C:\scripts\VMware> Get-VM | get-snapshot | select-object -expandproperty Name
Wed Jun 19 07:56:29 2013
PowerCLI C:\scripts\VMware> Get-VM | get-snapshot | select-object -expandproperty Created
Wednesday, June 19, 2013 7:57:18 AM
PowerCLI C:\scripts\VMware> Get-VM | get-snapshot | select-object -expandproperty Description
PowerCLI C:\scripts\VMware>

Open in new window

0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
I thought I posted in your question (Or I might posted this comment on another question ;-P )
Run the script by adding $att1.Dispose() after $smtp.Send($msg) and see if you can delete the excel file
0
 

Author Comment

by:namerg
Comment Utility
You got it. Subsun. That was it
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Synchronize a new Active Directory domain with an existing Office 365 tenant
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now