I just found this very interesting article.
I’m working on a way to register a large number of VM 300 1000 on the Disaster recovery vCenter and my tought goes to start-job PowerCli command.
But may be a workflow would be a better solution !?
I see that in the workflow construct you pass the session id to the parallelized process. Is it possible to do the same for the start-job or is mandatory that a new session to the vCenter has to be established ?
The number of sessions can impact the vCenter or the client performances ? I mean: Can I execute 300 parallel sessions to register 300 VM or (the way I think to proceed)is better to start a new job each 50 ones ?
Hi,
The PowerShell Workflow feature isn’t really being promoted by MSFT anymore I’m afraid.
To introduce parallelism, the Start-Job option is currently the better option.
And yes, you can use the same concept of passing the SessionId.
See my Running a background job dive.
I’m trying to use start-job but I receive these errors:
The Windows PowerShell snap-in ‘VMware.VimAutomation.Core’ is not installed on this computer.
+ CategoryInfo : InvalidArgument: (VMware.VimAutomation.Core:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
+ PSComputerName : localhost
The term ‘connect-viserver’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
+ CategoryInfo : ObjectNotFound: (connect-viserver:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : localhost
The term ‘Get-VMHostStorage’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, o
+ CategoryInfo : ObjectNotFound: (Get-VMHostStorage:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : localhost
But I’m inside the PowerCLI and the connect-viserver cmdlet works fine in the main session. May be I have to specify the location where the pssnapin are installed ?
I tried to omit the add-pssnapin line, to substitute it with the import-module command, executing it from a PowerCLI window and from a Powershell windows ( here I had to import-module for PowerCLI cmdlet working, but I have always the same error ( omitting the add-pssnapin I start with the connect-viserver error ).
Hi,
Depending on which PowerSHell version you use, it should find the modules automatically.
Check what folders are listed when you do
$env:PSModulePath.Split(';')
Is the folder where the PowerCLI modules are installed in that list?
When you are using a recent PowerCLI version (6.5.1 or higher, preferably 12.0), there are no PSSnapin anymore.
Pavlik
I just found this very interesting article.
I’m working on a way to register a large number of VM 300 1000 on the Disaster recovery vCenter and my tought goes to start-job PowerCli command.
But may be a workflow would be a better solution !?
I see that in the workflow construct you pass the session id to the parallelized process. Is it possible to do the same for the start-job or is mandatory that a new session to the vCenter has to be established ?
The number of sessions can impact the vCenter or the client performances ? I mean: Can I execute 300 parallel sessions to register 300 VM or (the way I think to proceed)is better to start a new job each 50 ones ?
Thanks
Pavlik
LucD
Hi,
The PowerShell Workflow feature isn’t really being promoted by MSFT anymore I’m afraid.
To introduce parallelism, the Start-Job option is currently the better option.
And yes, you can use the same concept of passing the SessionId.
See my Running a background job dive.
Pavlik
Thanks LucD,
your answers come always really fast and always very usefull.
Have a nice day.
Pavlik
Pavlik
I’m trying to use start-job but I receive these errors:
The Windows PowerShell snap-in ‘VMware.VimAutomation.Core’ is not installed on this computer.
+ CategoryInfo : InvalidArgument: (VMware.VimAutomation.Core:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
+ PSComputerName : localhost
The term ‘connect-viserver’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
+ CategoryInfo : ObjectNotFound: (connect-viserver:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : localhost
The term ‘Get-VMHostStorage’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, o
+ CategoryInfo : ObjectNotFound: (Get-VMHostStorage:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : localhost
But I’m inside the PowerCLI and the connect-viserver cmdlet works fine in the main session. May be I have to specify the location where the pssnapin are installed ?
This is the code:
do {
start-job -ScriptBlock {
param($vc,$c,$v)
Add-PSSnapin VMware.VimAutomation.Core
connect-viserver $vCenter -session $c
$v | Get-VMHostStorage -Refresh
} -RunAs32 -ArgumentList $vCenter,$global:DefaultVIServer.SessionSecret,$ListaVM[$cont..($cont + $delta – 1)]
I tried to omit the add-pssnapin line, to substitute it with the import-module command, executing it from a PowerCLI window and from a Powershell windows ( here I had to import-module for PowerCLI cmdlet working, but I have always the same error ( omitting the add-pssnapin I start with the connect-viserver error ).
Do you have an svice for me ?
Thanks
Pavlik
LucD
Hi,
Depending on which PowerSHell version you use, it should find the modules automatically.
Check what folders are listed when you do
$env:PSModulePath.Split(';')
Is the folder where the PowerCLI modules are installed in that list?
When you are using a recent PowerCLI version (6.5.1 or higher, preferably 12.0), there are no PSSnapin anymore.