Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Running Powershell Script with Orchestrator

Posted on 2013-06-12
1
Medium Priority
?
981 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
August and September have been big months for VMware—from VMworld last month to our new Course of the Month in VMware Professional - Data Center Virtualization. We reached out to Andrew Hancock, resident VMware vExpert, to have a more in-depth discu…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Loops Section Overview

824 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