Hello,
I have a template (Not Content Lib Template) and deploying VM through this with -OSCustomizationSpec Switch. However i can see the VM deployment task and could also locate the VM but somehow it is not applying -OSCustomization Spec. Any help Here?
Below is the Code.
$Template=Get-Template "SGAStemplate-WIN2012R2-20180301"
$mySpecification = Get-OSCustomizationSpec -Name RaaS-CRSR
New-VM -Name VMYouCanDelete -Template $Template -ResourcePool 'sol-mgmt' -OSCustomizationSpec $mySpecification
Error:
New-VM : 1/17/2019 10:13:37 AM New-VM Operation is not valid due to the
current state of the object.
At C:\users\Administrator\Desktop\Scripts\PowerShell\RaaS\TestCustSpec.ps1:4
char:1
+ New-VM -Name VMYouCanDelete -Template $Template -ResourcePool 'sol-mg ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.NewVM
That is a known issue, happened to me as well a couple of times.
Not sure if the problem is located with PowerShell or PowerCLI.
But I think it is a good practice to stop/start your PowerShell/PowerCLI sessions on a regular interval.
Independent if you are using it from a PS prompt, the ISE, the VSC...
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Which PowerCLI version are you using?
And which PowerShell version
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
And did you already try to stop/start the PowerShell/PowerCLI session form where you are running the script?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 6.7.0.8... VMware.DeployAutomation {Add-DeployRule, A...
Script 6.7.0.8... VMware.ImageBuilder {Add-EsxSoftwareDe...
Script 6.7.0.1... VMware.Vim
Script 11.0.0.... VMware.VimAutomation.Cis.Core {Connect-CisServer...
Script 11.0.0.... VMware.VimAutomation.Cloud {Add-CIDatastore, ...
Script 11.0.0.... VMware.VimAutomation.Common
Script 11.0.0.... VMware.VimAutomation.Core {Add-PassthroughDe...
Binary 6.0.0.0 VMware.VimAutomation.HA Get-DrmInfo
Script 7.6.0.1... VMware.VimAutomation.HorizonView {Connect-HVServer,...
Script 10.0.0.... VMware.VimAutomation.License Get-LicenseDataMan...
Binary 6.5.0.4... VMware.VimAutomation.PCloud {Connect-PIServer,...
Script 11.0.0.... VMware.VimAutomation.Sdk {Get-ErrorReport, ...
Script 11.0.0.... VMware.VimAutomation.Storage {Add-KeyManagement...
Script 11.0.0.... VMware.VimAutomation.Vds {Add-VDSwitchPhysi...
Script 10.0.0.... VMware.VimAutomation.vROps {Connect-OMServer,...
Script 6.5.1.7... VMware.VumAutomation {Add-EntityBaselin...
Name Value
---- -----
PSVersion 5.1.14409.1018
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1018
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Yes, I first tried with PoweShell ISE and letter tried with PowerCLI.exe
Did you already try with another template?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, After closing and restarting current PowerCLI session its not giving the error. Can you suggest on a permanent solution? Please. Should i use Remove-Variable * for the next VM to be deployed.
That is a known issue, happened to me as well a couple of times.
Not sure if the problem is located with PowerShell or PowerCLI.
But I think it is a good practice to stop/start your PowerShell/PowerCLI sessions on a regular interval.
Independent if you are using it from a PS prompt, the ISE, the VSC...
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, Looks like. I have a scenario where i am providing capability to users to deploy multiple VMs concurrently (Max 5 at a time) via PowerCLI script. Not sure how this will behave. Will update the thread once i am done with the UAT. Cheers LucD Thanks for your Help.
CC: abhishekmittal02
One solution I often use, is to place the script in a separate .ps1 file.
Then the main script, where the user can make choices, starts a PS session (with powershell.exe) and run the script.
The user's choices are passed as parameters to the script.
That way the script itself always runs in a fresh session.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference