Nothing happens when I execute the veeam powershell script?

PowerShell script exchange

Nothing happens when I execute the veeam powershell script?

Veeam Logoby daystrom » Sun Apr 09, 2017 6:52 pm

I have veeam 9.5 free, and would like to schedule a zip backup every day. I used the VeeamZIP (HV).ps1 script as a starting point. It seems straightforward - changed the vm name, the host name, set a valid destination path, turned off encryption and turned off EnableQuiescence. When I run the script via task manager (windows 2012 server) with highest privileges, it says "running" but nothing seems to happen. I terminate the task after about an hour - the backup should take 20 minutes. I don't see veeam using cpu or memory. No backup files are created.

How can I tell what is wrong? I haven't used powershell very much. I did update to ps 4 from 3, hoping that might help, but the test result was the same.
daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby Shestakov » Sun Apr 09, 2017 7:45 pm

Hello and welcome to the community!
It`s hard to say neither seeing the script nor the logs. Could you provide the script you are using?
Thanks!
Shestakov
Veeam Software
 
Posts: 4856
Liked: 394 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby vmniels » Sun Apr 09, 2017 7:59 pm

Also if you manually run the Powershell scripts does it work then?
VCP-DCV
Veeam Certified Engineer
http://foonet.be
vmniels
Veeam Software
 
Posts: 1504
Liked: 325 times
Joined: Mon Jul 15, 2013 11:09 am
Full Name: Niels Engelen

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby daystrom » Sun Apr 09, 2017 8:44 pm

Right...manually running, I'd forgotten that I tested that. It pops up a yes/no asking if I want to change the execution policy. I've never told it to change the policy. I guess this is a barrier to malware or something. And it probably explains why it just does nothing via task manager. I will allow the change and try it again. Did that - ps window stayed open for a few seconds and then closed. It's been five minutes and I don't see any new vbk files. The sql server instanced that is used by veeam is somewhat active, but none of the other veeam services are. Not sure what it adds up to?

Not knowing ps - should I expect to see the ps window stay open as long as the script that was executed is in play? But maybe the script is over almost immediately, and now veeam should be doing it's thing according to the parameters?
daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby vmniels » Sun Apr 09, 2017 8:49 pm

Do you see a running job in the Veeam GUI and if so what is the status saying?
VCP-DCV
Veeam Certified Engineer
http://foonet.be
vmniels
Veeam Software
 
Posts: 1504
Liked: 325 times
Joined: Mon Jul 15, 2013 11:09 am
Full Name: Niels Engelen

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby daystrom » Sun Apr 09, 2017 9:32 pm

I don't see a job running.
I wonder if the issue is the host name? I have entered the name of the server that veeam is running on and which is also the host of the vms.

# Name of vCenter or standalone host VMs to backup reside on (Mandatory)
$HostName = "AMA-VH01"

But I noticed that the connection when I log on to veeam is simply localhost. It should mean the same thing. The dialog that veeam presents which specifies the connection to localhost was not there in the older version of veeam I was using before (8.0)
daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby vmniels » Sun Apr 09, 2017 10:39 pm

Can you ping that hostname from the server you are running the script? You need to use the hypervisor hostname or IP (if you can't resolve it).
VCP-DCV
Veeam Certified Engineer
http://foonet.be
vmniels
Veeam Software
 
Posts: 1504
Liked: 325 times
Joined: Mon Jul 15, 2013 11:09 am
Full Name: Niels Engelen

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby daystrom » Sun Apr 09, 2017 11:57 pm

It's the same server. Very simple setup, one physical box, AMA-VH01, which has veeam installed, and hosts the two vms I want to back up with veeam.
daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby daystrom » Mon Apr 10, 2017 12:14 am

here is the script; guess I have to post it here in the msg.

Code: Select all
# Author: Vladimir Eremin
# Created Date: 3/24/2015
# http://forums.veeam.com/member31097.html
#

# 20170408 modified from VeeamZIP (HV).ps1
 
##################################################################
#                   User Defined Variables
##################################################################

# Names of VMs to backup separated by comma (Mandatory). For instance, $VMNames = “VM1”,”VM2”
$VMNames = "AMA-DC1"

# Name of vCenter or standalone host VMs to backup reside on (Mandatory)
$HostName = "AMA-VH01"

# Directory that VM backups should go to (Mandatory; for instance, C:\Backup)
$Directory = "G:\ama vm images"

# Desired compression level (Optional; Possible values: 0 - None, 4 - Dedupe-friendly, 5 - Optimal, 6 - High, 9 - Extreme)
$CompressionLevel = "5"

# Quiesce VM when taking snapshot (Optional; VMware Tools are required; Possible values: $True/$False)
$EnableQuiescence = $False

# Protect resulting backup with encryption key (Optional; $True/$False)
$EnableEncryption = $False

# Encryption Key (Optional; path to a secure string)
$EncryptionKey = ""

# Retention settings (Optional; By default, VeeamZIP files are not removed and kept in the specified location for an indefinite period of time.
# Possible values: Never , Tonight, TomorrowNight, In3days, In1Week, In2Weeks, In1Month)
$Retention = "In1Week"

##################################################################
#                   Notification Settings
##################################################################

# Enable notification (Optional)
$EnableNotification = $False

# Email SMTP server
$SMTPServer = ""

# Email FROM
$EmailFrom = ""

# Email TO
$EmailTo = ""

# Email subject
$EmailSubject = ""

##################################################################
#                   Email formatting
##################################################################

$style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 5px; }"
$style = $style + "</style>"

##################################################################
#                   End User Defined Variables
##################################################################

#################### DO NOT MODIFY PAST THIS LINE ################
Asnp VeeamPSSnapin

$Server = Get-VBRServer -name $HostName
$MesssagyBody = @()

foreach ($VMName in $VMNames)
{
  $VM = Find-VBRHvEntity -Name $VMName -Server $Server
 
  If ($EnableEncryption)
  {
    $EncryptionKey = Add-VBREncryptionKey -Password (cat $EncryptionKey | ConvertTo-SecureString)
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention -EncryptionKey $EncryptionKey
  }
 
  Else
  {
    $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $CompressionLevel -DisableQuiesce:(!$EnableQuiescence) -AutoDelete $Retention
  }
 
  If ($EnableNotification)
  {
    $TaskSessions = $ZIPSession.GetTaskSessions().logger.getlog().updatedrecords
    $FailedSessions =  $TaskSessions | where {$_.status -eq "EWarning" -or $_.Status -eq "EFailed"}
 
  if ($FailedSessions -ne $Null)
  {
    $MesssagyBody = $MesssagyBody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result,@{n="Details";e={$FailedSessions.Title}})
  }
   
  Else
  {
    $MesssagyBody = $MesssagyBody + ($ZIPSession | Select-Object @{n="Name";e={($_.name).Substring(0, $_.name.LastIndexOf("("))}} ,@{n="Start Time";e={$_.CreationTime}},@{n="End Time";e={$_.EndTime}},Result,@{n="Details";e={($TaskSessions | sort creationtime -Descending | select -first 1).Title}})
  }
 
  }   
}
If ($EnableNotification)
{
$Message = New-Object System.Net.Mail.MailMessage $EmailFrom, $EmailTo
$Message.Subject = $EmailSubject
$Message.IsBodyHTML = $True
$message.Body = $MesssagyBody | ConvertTo-Html -head $style | Out-String
$SMTP = New-Object Net.Mail.SmtpClient($SMTPServer)
$SMTP.Send($Message)
}


daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby Mike Resseler » Mon Apr 10, 2017 6:42 am

Hi Daystrom,

Let's start with an easy check. Can you open windows powershell ISE and run it as an administrator? Then run the script from in there. The advantage is that the pane will stay open so you can see what is happening (maybe it is asking a question somewhere).

Let us know what it does
Mike Resseler
Veeam Software
 
Posts: 3150
Liked: 362 times
Joined: Fri Feb 08, 2013 3:08 pm
Location: Belgium, the land of the fries, the beer, the chocolate and the diamonds...
Full Name: Mike Resseler

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby v.Eremin » Mon Apr 10, 2017 12:07 pm

Also, it might be verifying whether server and VM variables get assigned properly, use the following script to confirm that:

Code: Select all
Asnp VeeamPSSnapin
$VMNames = "AMA-DC1"
$HostName = "AMA-VH01"
$Server = Get-VBRServer -name $HostName
$Server
$VM = Find-VBRHvEntity -Name $VMName -Server $Server
$VM


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby daystrom » Mon Apr 10, 2017 6:13 pm

Thanks for those ps tips, new turf for me, and interesting.
running the script via admin ps shows this:

Start-VBRZip : Cannot validate argument on parameter 'Entity'. The argument is null. Provide a valid value for the
argument, and then try running the command again.
At C:\scripts\VeeamZIP_mms.ps1:88 char:40
+ $ZIPSession = Start-VBRZip -Entity $VM -Folder $Directory -Compression $Comp ...
+ ~~~
+ CategoryInfo : InvalidData: (:) [Start-VBRZip], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.StartVBRZip

I don't see a parameter 'Entity' in the script?
daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby daystrom » Mon Apr 10, 2017 6:18 pm

I ran the test script.

PS C:\scripts> .\test01.ps1

Info : ama-vh01 (Microsoft Hyper-V Server)
ParentId : 00000000-0000-0000-0000-000000000000
Id : 1b42f5d8-2c94-4c16-bcb6-0e0b93d98721
Name : ama-vh01
Reference :
Description : Created by AMA\someadmin at 12/14/2015 3:07:19 PM.
IsUnavailable : False
Type : HvServer
ApiVersion : Unknown
PhysHostId : d7c4ff97-b99b-4d1f-884d-283b7b6b9ee3
ProxyServicesCreds : Veeam.Backup.Common.CCredentials

Find-VBRHvEntity : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument
that is not null or empty, and then try the command again.
At C:\scripts\test01.ps1:6 char:30
+ $VM = Find-VBRHvEntity -Name $VMName -Server $Server
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Find-VBRHvEntity], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.FindVBRHvEntity
daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby Mike Resseler » Mon Apr 10, 2017 6:43 pm

Just noticed (at least I think) that V.Eremin probably has a typo in that test script

Code: Select all
Asnp VeeamPSSnapin
$VMName = "AMA-DC1"
$HostName = "AMA-VH01"
$Server = Get-VBRServer -name $HostName
$Server
$VM = Find-VBRHvEntity -Name $VMName -Server $Server
$VM


Can you try again with the above code? (The variable name for the VM didn't match the variable name in the last line (an S too much) :-)
Mike Resseler
Veeam Software
 
Posts: 3150
Liked: 362 times
Joined: Fri Feb 08, 2013 3:08 pm
Location: Belgium, the land of the fries, the beer, the chocolate and the diamonds...
Full Name: Mike Resseler

Re: Nothing happens when I execute the veeam powershell scri

Veeam Logoby daystrom » Mon Apr 10, 2017 6:55 pm

Right, with the revised script it returned this:

PS C:\scripts> .\test01.ps1

Info : ama-vh01 (Microsoft Hyper-V Server)
ParentId : 00000000-0000-0000-0000-000000000000
Id : 1b42f5d8-2c94-4c16-bcb6-0e0b93d98721
Name : ama-vh01
Reference :
Description : Created by AMA\someadmin at 12/14/2015 3:07:19 PM.
IsUnavailable : False
Type : HvServer
ApiVersion : Unknown
PhysHostId : d7c4ff97-b99b-4d1f-884d-283b7b6b9ee3
ProxyServicesCreds : Veeam.Backup.Common.CCredentials
daystrom
Influencer
 
Posts: 15
Liked: never
Joined: Sun Apr 09, 2017 6:32 pm

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests