I have to drop back to the below code to ask a question before trying the error code,,,,
Question is at the bottom,.,
------------------------------------------------------
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false -Confirm:$false
Set-PowerCLIConfiguration -DisplayDeprecationWarning:$true
Connect-VIServer -Server $vcenter_server -User $user -Password $decryptedPassword
$ds = Get-Datastore | where{$_.Type -eq 'VMFS' -and $_.ExtensionData.Summary.MultipleHostAccess} |
Sort-Object -Property FreeSpaceGB -Descending | select -First 1
$esx = Get-Cluster -VM $vmName | Get-VMHost | Get-Random
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Set up cloning names - remove the day before
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$cloneName = "$($vmName)-clone-$((Get-Date).ToString('MMddyyyy'))"
$oldCloneName = "$($vmName)-clone-$((Get-Date).AddDays(-1).ToString('MMddyyyy'))"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Get the idm02 clone and remove the day before clone
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Get-VM -Name $oldCloneName -ErrorAction SilentlyContinue |
Remove-VM -DeletePermanently:$true -Confirm:$false
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Clone idm02 to curernt day
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
New-VM -VM $vmName -Name $cloneName -Datastore $ds -Location $Folder -VMHost $esx
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# disconnect from vCenter
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!
Disconnect-VIServer -Server $vcenter_server -Confirm:$false
exit 0
------------------------------------------------------------------------
If I go to the Task Manager in Windows and right click on the task and select run to execute the above script, I get a PowerShell window that pops up with the below and the window just stays up.
How do I stop the PowerShell window from opening when I right click and select "run"?
Scope ProxyPolicy DefaultVIServerMode InvalidCertificateAction DisplayDeprecationWarnings WebOperationTimeout
Seconds
----- ----------- ------------------- ------------------------ -------------------------- -------------------
Session UseSystemProxy Single Ignore True 300
User Single Ignore True
AllUsers
Perform operation?
Performing operation 'Update PowerCLI configuration.'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):