Solved

Running Powershell Script with Orchestrator

Posted on 2013-06-12
1
918 Views
Last Modified: 2013-06-12
The script works fine, but when run in Orhestrator I receive the following error:
error summary text: Only administrators can change settings for all users

This does not give me any clue.

The code gibberish below is from Orhestrator that is used for mapping values from other parts of the runbook to the script:
$vCenterHost = "xx.xx.xx.xx"
$vCenterUser = "xxx\xxxxxxxx"
$vCenterPass = "xxxxxxxx" 

$vmcluster = "\`d.T.~Ed/{3CE14789-2A92-4CFA-9D49-07125D3B5632}.{6004C665-6069-46F9-B0FC-496CBFD3B2AD}\`d.T.~Ed/"
$datastorecluster = "\`d.T.~Ed/{3CE14789-2A92-4CFA-9D49-07125D3B5632}.{8B61C2D5-95E5-45BF-9817-1618132FAFE6}\`d.T.~Ed/"
$ErrorID = 0

$vmname = "\`d.T.~Ed/{3CE14789-2A92-4CFA-9D49-07125D3B5632}.{518C9136-0F46-4B22-AA83-D716176BFA8E}\`d.T.~Ed/"
$NumCpu = \`d.T.~Ed/{3CE14789-2A92-4CFA-9D49-07125D3B5632}.{148BAB6B-AA13-409D-84F3-5CFCF5D68D2E}\`d.T.~Ed/
$MemoryGB = \`d.T.~Ed/{3CE14789-2A92-4CFA-9D49-07125D3B5632}.{E266FB8E-D17C-4ED7-8EDA-686BCB994948}\`d.T.~Ed/
$DiskStorageFormat = "\`d.T.~Ed/{3CE14789-2A92-4CFA-9D49-07125D3B5632}.{F9F636A5-3CE0-4B2E-81B9-AB0760979C15}\`d.T.~Ed/"
$osversion = "\`d.T.~Ed/{3CE14789-2A92-4CFA-9D49-07125D3B5632}.{1E4F231A-98EC-4196-815C-F69D2C1813F2}\`d.T.~Ed/"

if(-not (Get-PSSnapin VMware.VimAutomation.Core)) { 
    Add-PSSnapin VMware.VimAutomation.Core 
} 

Set-PowerCLIConfiguration -DefaultVIServerMode Single -InvalidCertificateAction Ignore -confirm:$false
Connect-VIServer -Server $vCenterHost -User $vCenterUser -Password $vCenterPass

$vmname = $vmname.toUpper()

try {
      $name = ((Get-VM $vmname).name).toUpper()
} catch {

}
if ($name -eq $vmname) { 

	# Server exists

	$ErrorID = "1"
	throw "ERROR: 1 A server already exists with the same name" 
}

$osversion = $osversion.toUpper()

switch ($osversion)  { 
              "WIN2012" {	"Windows 2012"
			$OSCustomizationSpec = "W2K12-SE-64-CUSTOMIZATION"
			$vmtemplate = "win2012_template"
		} 
	"WIN2008" {	"windows 2008"
			$OSCustomizationSpec = "W2K8-SE-64-CUSTOMIZATION"
			$vmtemplate = "W2K8-R2-SE-64-MAL"
		} 
        
	default { 
			$ErrorID = "2"
	                                throw "ERROR: 2 Unknown OS version" 
                            }

    }

$vmcluster = $vmcluster.toUpper()

switch ($vmcluster) { 
       	"HOSTECluster_xx" {	
			"annet cluster"
				  
			} 
        
	default { 
			"VMCluster was set to default"
			$vmcluster = "CLUSTER 1"
		}
    }

$datastorecluster = $datastorecluster.toUpper()

switch ($datastorecluster) { 
       	"DatastoreCluster_xx" {	
			"Another datastore"
				  
			} 
        
	default { 
			"Datastore Cluster was set to default"
			$datastorecluster = "DatastoreCluster_01"
		}
    }

Get-Cluster $vmcluster | New-VM -Name $vmname -OSCustomizationSpec $OSCustomizationSpec -DiskStorageFormat $DiskStorageFormat -Template $vmtemplate -Datastore $datastorecluster
Get-VM $vmname | Set-VM -NumCpu $NumCpu -MemoryGB $MemoryGB -confirm:$false
Get-VM $vmname | Start-VM

Open in new window

0
Comment
Question by:itnifl
1 Comment
 
LVL 2

Accepted Solution

by:
itnifl earned 0 total points
ID: 39240987
I turned off UAC
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …
Teach the user how to install and configure the vCenter Orchestrator virtual appliance Open vSphere Web Client: Deploy vCenter Orchestrator virtual appliance OVA file: Verify vCenter Orchestrator virtual appliance boots successfully: Connect to the …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now