Ok I'm still a novice but I have a script that will check for new resource pool in vCenter then add new backup job in Veeam
This is just a part of the script that will run INVOKE-COMMAND portion and it is not passing Variables from local to remote session
Just a part of script ((((assume $targetfolder, $crmid, $pool)))) have been correctly supplied locally
$remotesession = New-PSSession -Name VBUserver -ComputerName $VBUserver -credential $cred
invoke-command -computername $VBUserver -credential $cred -Script{
param($targetfolder,$crmid,$pool)
add-pssnapin VeeamPSSnapIn
$vbrserver = Get-VBRServer | Where {$_.Type -eq "Local"}
add-vbrbackupjob $crmid VDDK $vbrserver $targetfolder -objects $pool
}
Any help would be awesome
Erik
-
- Novice
- Posts: 3
- Liked: never
- Joined: Jan 04, 2012 11:37 pm
- Full Name: Erik Stoeffels
- Contact:
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: Invoke-Command with Variables
invoke-command doesn't have a -script flag from what I know, it only has scriptblock. Try changing it to scriptblock and see if that works. Also, you could do the following:
Code: Select all
invoke-command -Computer BNRBox -ScriptBlock {add-pssnapin VeeamPSSnapIn;$vbrserver = Get-VBRServer | Where {$_.Type -eq "Local"};add-vbrbackupjob $crmid VDDK $vbrserver $targetfolder -objects $pool}
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
-
- Veteran
- Posts: 293
- Liked: 19 times
- Joined: Apr 13, 2011 12:45 pm
- Full Name: Thomas McConnell
- Contact:
Re: Invoke-Command with Variables
This should work;
[added]
Is this v5 or v6?
Code: Select all
$remoteSession = New-PSSession -Name VBUserver -ComputerName $VBUserver -Credential $cred
Invoke-Command -Session $remoteSession -ScriptBlock {
param(
$targetfolder,
$crmid,
$pool
)
add-pssnapin VeeamPSSnapIn
$vbrserver = Get-VBRServer | Where {$_.Type -eq "Local"}
add-vbrbackupjob $crmid VDDK $vbrserver $targetfolder -objects $pool
} -ArgumentList "$targetfolderValue", "$crmidValue", "$poolValue"
Is this v5 or v6?
Who is online
Users browsing this forum: No registered users and 9 guests