Solved

Running Powershell Script with Orchestrator

Posted on 2013-06-12
1
939 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

856 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