Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 207266

Export CSV doesn't update the file when it runs via Task Scheduler

$
0
0

Hello,

Long time haven't posted in VMWare forum.. I have a script which generates the hosts UpTime and export the result to CSV file. Then it sends the CSV file as attachment to our helpdesk system. When I run the script manually through PowerCLI ./Get-HostUpTime.ps1 it runs fine and it sends the updated file, however, when the script runs through the Windows Task Scheduler, it runs fine but it doesn't update the CSV file and it always sends the old one.

 

$username = 'Administrator'

$password = 'password'

$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

Connect-VIServer -Server vCenter01 -Credential $cred

 

Get-View -ViewType "HostSystem" -property Name, Summary | `

where {

  $_.name -like "*" } |`

   select Name, @{N="Uptime"; E={(Get-Date) - $_.Summary.Runtime.BootTime}

} |sort Name | Export-csv C:\Scripts\HostsUpTime.csv

 

Disconnect-VIServer -confirm:$false

 

Send-MailMessage -From vSphere@Domain.com -To helpdesk@Domain.com -Subject "vSphere Hosts UpTime" -SmtpServer SMTPHUB001 -Attachments C:\Scripts\HostsUpTime.csv

Any help?

Thanks,


Viewing all articles
Browse latest Browse all 207266

Trending Articles


Practice Sheet of Right form of verbs for HSC Students


Rajasthan Board 10th Result 2016 Roll No wise & Name Wise


Moondru Mudichu 20-07-2016 – Polimer tv Serial


fs_older_downloads


Calaveras conflict results in shooting, 4 arrests


Guilty Pleasures


Black Angus Grilled Artichokes


Download: Rich Bizzy -Panono Ukwenda (Cover)


Muloraki Au


where in jaunpur randi khana



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>