Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 207710

Script failes after running perfectly for some time

$
0
0

Hi.

 

I hope you can help me.

 

We are trying to create a powershell script, that can create all our new VM's.

 

The problem is, that this script runs perfectly for some time, and then fails constantly afterwards.

We can create 5 - 10 VM's before it fails.

 

When it then fails, it still creates the VM, but fails to change network adapter, or start the VM.

 

The scripts is :

 

-


Add-PSSnapin VMWare.vimAutomation.Core

Remove-Variable -Name * -Force -Confirm:$false -ErrorAction silentlycontinue 

 

$VISRV = Connect-VIServer viappdk001.ad.nss.nnit.com -password xxxxxxxxx -User Vmware_SDS_createvm > $null

 

$Obj_RNDNAME = New-Object  System.Random

$RNDNAME = 'VM'+$Obj_RNDNAME.Next()

 

New-VM -VMHost nssvmdk009.ad.nss.nnit.com -Name $RNDNAME -GuestId winLonghornGuest -diskmb 50000 -MemoryMB 1024 -NumCpu 1 -Server $VISRV 

 

$adapter = Get-NetworkAdapter -VM $RNDNAME

Remove-NetworkAdapter -NetworkAdapter $adapter -Confirm:$false

 

$vm = Get-VM $RNDNAME

New-NetworkAdapter -VM $vm -StartConnected:$true -Type Vmxnet3 -NetworkName "VM_Deployment_Vlan999" -Confirm:$false

 

Start-VM -VM $vm -Confirm:$false

 

Disconnect-VIServer -Confirm:$False

 

Remove-Variable -Name * -Force -Confirm:$false -ErrorAction silentlycontinue 

 

-


 

When it fails, we get the following error messages.

 

-


 

Cannot add Windows PowerShell snap-in VMWare.vimAutomation.Core because it is already added. Verify the name of the snap-in and try again.

At :line:1 char:12

+ Add-PSSnapin <<<<  VMWare.vimAutomation.Core

 

WARNING: There were one or more problems with the server certificate:

 

  • The X509 chain could not be built up to the root certificate.

 

 

 

7/15/2010 9:59:07 AM     New-VM          Unsufficient permissions. You need 'System.Read' privileges to complete the requested operation.     

At :line:9 char:6

+ New-VM <<<<  -VMHost nssvmdk009.ad.nss.nnit.com -Name $RNDNAME -GuestId winLonghornGuest -diskmb 50000 -MemoryMB 1024 -NumCpu 1 -Server $VISRV

 

-


 

I can see that this i a permision thing, but the script runs fine the first 5 - 10 times.

The account is not locked out, and i can log on to vCenter, and perform the came actions manualy, that the script is suposed to do, before and after the script fails.

 

Any ideas ?

 

Thanks

 

/Robert


Viewing all articles
Browse latest Browse all 207710

Trending Articles



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