PowerShell, selcetable lists
Hello
I'm starting a small project of powershell for automation to failover to the boxes in DR (failover in offline mode)
I stumbled at the first hurdle. I would like to create dynamic, selectable lists for my users to tro responds when you are prompted.
for example, I want to invite a user to select a data store in the warehouses of data available in the VirtualCentre.
for example I want in the background running ' get-resourcepool | Select name '
generation of unelistede like:
Prod_DS1
Prod_DS2
Dev_DS1
Dev_DS2
Dev_DS3
Uat_DS1 etc.
the user must obtain:
Please select a data store in the list:
1 Prod_DS1
2 Prod_DS2
3 Dev_DS1
4 Dev_DS2
5 Dev_DS3
6 Uat_DS1
They should just type a number.
How about this?
$x = @(0) * 20 # initialize the array $i=0 # intialize the indexer get-resourcepool ` | select -first 20 ` | % { $x[$i]=$_.Name; "{0} {1}" -f $i++, $_.Name } # store the resource pools into an array and display the array $index = read-host index # ask for an index $x[$index] # display the name matching the given index
Or... as a good word:
$x = @(0) * 20; $i=0; get-resourcepool | select -first 20 | % { $x[$i]=$_.Name; "{0} {1}" -f $i++, $_.Name } ; $index = read-host index ; $x[$index]
Tags: VMware
Similar Questions
-
problem uninstalling windows powershell 1.0
An interesting problem - I tried to install windows xp professional on windows xp family and received the message that xp pro cannot be installed on windows powershell 1.0. So I used appwiz.cpl in the command prompt and windows powershell is not listed as being installed. So I went through Control Panel/Add / Remove programs and it is not listed, it will fade.
But when I click on Star/All programs - windows powershell is listed in effect and it works!
How to uninstall windows powershell?
Above is a link to the XP newsgroups.
They may be able to help with your problem related to the XP.
http://support.Microsoft.com/default.aspx/KB/926140
To the bottom of the MS above link is the uninstaller for Windows Powershell News:
To uninstall Windows PowerShell 1.0, follow these steps:
- Click Start, click run, type appwiz.cpl, and then click OK.
- Click to select the Show updates check box.
- In the currently installed programs list, click Windows PowerShell (TM) 1.0, and then click Remove.
- Follow the instructions to remove Windows PowerShell (TM) 1.0.
Here is the Vista Forums.
See you soon. Mick Murphy - Microsoft partner
-
Cannot find the powershell x 64 in my menu accessories
I do not seem to have PowerShell 64 listed in my menu accessories x more, don't know how it happened or when it happened.
Is there a way to recover or reinstall without making a complete sys. recovery.
I have a HP sys. Windows 7 x 64 home Prem
I went in my WOW64 folder to see if he was there but couldn't find it.
You can create your own shortcuts to Powershell. I have included all four, and I see that the 32 bits that are presented in syswow64 as expected. The 64 bits are in different folders.
64 bit
Windows Powershell - %windir%\system32\WindowsPowerShell\v1.0\powershell.exe
Windows PowerShell ISE - %windir%\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe
32 bit
Windows PowerShell (x86)-%windir%\syswow64\WindowsPowerShell\v1.0\powershell.exe
Windows PowerShell ISE (x86)-%windir%\sysWOW64\WindowsPowerShell\v1.0\PowerShell_ISE.exe
There is a help file to the
%windir%\Help\mui\0409\WindowsPowerShellHelp.chm
- - - - - - - - - - - - - - - -
I noticed that you do not have file extensions are displayed. It belongs to you, but some malicious programs trying to get you to the launch by exploiting this situation. They might rename an executable, as, for example, a PDF to open carelessly to see what is in the 'document '. If the full name can be
ReadMe.pdf.exe
but all you see is
ReadMe.pdf
You can change this setting in the Union view tab, folder & search options, by clearing the check box to Hide extensions of known file types.
-
Orchestrator + powershell script: variable
Hello
I want to create a workflow with an external script powershell and "scriptable task."
First step:
1. I set my input parameters in the "Task Scriptable" and "script" my variable entry for the external script powershell tab: scriptArgs = Variable1 + "" + Variable2;
2. I get my variable in my outside first PowerShell script-> at this point it's OK
3. in my outside first powershell script, I create variables $var1 and $var2
Second step:
1. I created a 'Scriptable task' and I want to get an exit powershell ($var1 and $var2) as a starter for my 'scriptable task. "
I don't know how passing a powershell variable to any other 'workflow element' or 'scriptable task. "
Invoke an external PS workflow script returns as objects of the output of type PowerShell:PowerShellRemotePSObject.
You can use it to extract data from the output of the powershell script. Example is provided with the plugin inside the folder library/PowerShell/samples/list directory content workflow
You can use PowerShell:PowerShellRemotePSObject to receive the output as raw xml, PowerShell:PowerShellRemotePSObject.getXml() data or using getRootObject() directlyas objects of type PowerShellPSObject, and then use getProperty (xxx)...
Here is an excerpt of the example workflow to browse the list of files returned as a result of the invocation of the ps script.
// Get PowerShellRemotePSObject var psObject = invResult.getResults(); var directories = psObject.getRootObject(); var isList = directories instanceof Array if ( isList ){ for (idx in directories){ var item = directories[idx]; if ( item.instanceOf('System.IO.FileInfo') ){//check type of object System.log( item.getProperty('FullName') );//extract value from result } } } else { System.log( directories.getProperty('FullName') );//extract value from result } } ...
-
ThinkPad L460, cannot get the BIOS through WMI settings
We used the official instructions and VBscripts Lenovo to set up the BIOS on the laptop ThinkPad T440, T450, L440 and L450 via WMI. It worked well for a while now.
A few weeks back, we received our first batch of portable computers ThinkPad L460 (with 10 of Windows), and I went to check and update the scripts of BIOS. The first thing I tried was to get a list of all the BIOS settings, the use of the ListAll.vbs script (available from the link above) and then through the PowerShell commands listed in the PDF (skl_deploy_01.pdf).
On previous models of ThinkPad the ListAll.vbs script would return a long list of avilable BIOS settings (or "configuration items") as well as their current and possible values. On the L460 that it returns nothing, not even an error message:
C:\temp\Script>cscript ListAll.vbs
Microsoft (R) Windows Script Host versjon 5.812
Copyright (C) Microsoft Corporation. Med EnerettC:\temp\Script >
This isn't the same performance you'd get if you run the script not elevated command or on a non-Lenovo computer. In these cases, the output looks like this:
C:\temp\Script>cscript ListAll.vbs
Microsoft (R) Windows Script Host versjon 5.812
Copyright (C) Microsoft Corporation. Med Enerettcurrent value =
possible settings =.C:\temp\Script >
I found an old net on the forum describing a similar problem and suggesting it was caused by a third-party software or a customized image of Windows, but the issue is present on both W10 Pro portable computers L460 stocks provided with images, a clean install of W10 Pro version 1511 (ISO downloaded directly from Microsoft) and images of company W10 custom of my organization.
I tried upgrading the BIOS to the most recent available (1.13). That did not help.
Anyone have any ideas on what could be the cause? We received a pretty low amount of laptops L460 so far, so it's kind of feasible to configure all the parameters of the BIOS by hand, but I prefer not having to do once the laptops start to arrive in large numbers. It is both a waste of time and error compared to the configuration script.
-
Find unused virtual machines in the data store
I am interested if anyone has a powershell script list virtual machines in a store of data that does not currently exist in vCenter inventory? Basically, I have a problem when users often delete the vCenter inventory virtual computer but leave the VM disk. Thanks in advance for your comments and suggestions.
Do not know what position you found, but may also take a look at my post of Raiders of the lost VMX
____________
Blog: LucD notes
Twitter: lucd22
-
Cannot delete vm orphan and inaccessible from the inventory.
An accident during a svmotion, vm orphans and tried to readd to the inventory, but not luck. I have since restored the virtual machine from a snapshot of the san and removed all the original files and it is now part of a new folder, but I can't remove 2 items in inventory that I tried from it readd after the initial failure.
I restarted the server, I rebooted mgmt-vmware and vmware-vmkauthd vpxa. -several times now.
VMware-cmd - l host does not list any reference to the virtual machine ghost. Cannot remove vclient
vitoolkit (powershell) will list the 2 vms,
get-vm-name vmname -
product name of the virtual computer object.
but I can not:
get-vm-name vmname | remove-vm -does not work because I get this error message... "Remove-VM: 2009-05-11 21:05:02 delete VM a general error has occurred: you must turn off the virtual machine and complete the migration before this operation is called. »
nothing I've tried annoys me to remove the orphan.
I worked with vmware on this issue support and ended up coming up with my own 'solution' if it's that a cluster just a fix is quite simple... I had the same symptoms you had as well...
1. place the knot in Maint Mode
2 remove the node from the Cluster
3 Add the node in the Cluster.
Presto - fixed.
Question of fact, here's my thread of origin on this issue. http://communities.VMware.com/thread/203764?TSTART=0
According to me, the only drawback is that if you have Pools of resources in place it will be those screw up on this node/vm... but is it really wasn't a question/problem for me in my case...
-
-
Need help to sort a column in the classic report
Hi I'm creating and classic report and I need to sort on the columns. I also use a selection list to filter the records in the column. When I do not use the list selection sorting works but when I'm on the selcet list and select the sort option, then it is showing error. If anyone can help...
Thnaks,
RikHello
Is it possible see the source code?
If you create the developer user to your workspace and post login information.
Or you can send information to connect to me by e-mail. My email is in my profileKind regards
Jari -
I have powershell on my Start menu, but it does not appear in Add/Remove, even w / 'show updates' checked. I checked for updates kb926139, kb926140 and kb926141. None of those appear no more, even w / 'show updates' ticked. I tried to run, type appwiz.cpl, 'show updates' with the same result. I don't want or need this program and wish to get rid of him, if I can do it easily and safely. Not a user experienced, so I can't go digging around in my directory for the files, because I know not even how to get into the directory! Can anyone help? Have xpsp3
I have powershell on my Start menu, but it does not appear in Add/Remove, even w / 'show updates' checked. I checked for updates kb926139, kb926140 and kb926141. None of those appear no more, even w / 'show updates' ticked. I tried to run, type appwiz.cpl, 'show updates' with the same result. I don't want or need this program and wish to get rid of him, if I can do it easily and safely. Not a user experienced, so I can't go digging around in my directory for the files, because I know not even how to get into the directory! Can anyone help? Have xpsp3He is listed as Windows Powershell. Maybe you just looked for Powershell. You were just to check the brand of show updates.
I do not vote for me I'm not here for points. If this post helps you, vote. Visit my forum @ http://repairbotsonline.com/ -
How to remove Windows PowerShell 2.0, while all my update lists are lost?
Hello
I'm terriblely sorry that I am a Chinese, as China MS can not solve the problem, I ask you for help.
All my lists update are lost, this means while I opened the update of lists, it's empty, but all my updates are installed on the computer.
If I can't remove Windows PowerShell, I can not test compatibility of Vista so I can't use the upgrade to repair the operating system.
Thank you, if you can help, I know how to use CMD to delete PowerShell 1.0 but it cannot be used for 2.0 and msicuu2 cannot remove updates, if using the MS means do not work, I hope you can tell me how to use software from other producers to remove Windows PowerShell 2.0.
Thanks again.
Unless you format the drive HARD and then do a clean install of Vista & then get SP2 installed to switch to Win7, your best bet would be a fresh install of Win7.
In other words, the presence of Windows PowerShell 2.0 isn't your problem - a system infected with hijackware is your problem.
-
Need a powershell script to create a local user on esx given the esx server list box
Hello
I need a powershell script to create a local user on esx in a given list entry of esx servers through a csv spreadsheet. The script should ask me the user name and the password for the user name to be created on the given list of esx servers.
Thanks in advance!
Just noticed that there is a lack of vacuum after the - password parameter.
It should be
$userName = Read-Host "Username" $password = Read-Host "Password" -AsSecureString:$true Import-Csv "C:\vmhosts.csv" | %{ Connect-VIServer -Server $_.Hostname -Credential (Get-Credential) New-VMHostAccount -Id $userName -Password $password -UserAccount:$true -GrantShellAccess:$true -Confirm:$false Disconnect-VIServer -Confirm:$false }
____________
Blog: LucD notes
Twitter: lucd22
-
PowerShell list replica Replays
I am trying to automate DR creating replays of replica to mount a view to guests. I need to enumerate the replays before I can mount them, but when I try to enumerate the replays on the replica volumes, nothing is returned.
For example:
Get-SCReplay - SourceSCVolume $myVolume - $myConnection Connection
When $myVolume is a local volume (not replicated) This returns a list of replays. When $myVolume is a replica (from another storage Center) this command returns nothing.
Any ideas? I go about it the wrong way? I turned to scripts such as the features of Enterprise Manager Active / Test DR are not large enough to meet my needs.
-Jonathan
I think that if you change your Get-SCReplay line for this, it should work.
Get-SCReplay - SourceVolumeIndex $myVolume.Index - $myConnection Connection
-
Need a PowerShell Script to list all my stores of data, capacity and VMFS format.
All,
I need a script to list all my stores of data, capacity and VMFS format.
That's what I have so far but its does not give me the results I need.
Get-Datastore - Datacenter MN_PROD | where {$_.} Type - eq "VMFS"} | Select-Object Name,@{N="VMFS version. {E = {$_.Info.Vmfs.Version}}
Try like this
Get-Datastore -Datacenter MN_PROD | where {$_.Type -eq "VMFS"} | Select-Object Name,CapacityGB, @{N="VMFS version";E={$_.FileSystemVersion}}
-
PowerShell code to list all VM by Datastore
Hello world
I got the following script to list all of the virtual machine by the data store, but somehow it does not store data (empty) for some virtual machines?
Get-data center | Get - VM | %{ $_. Name + " - " + (($_ | Get-Datastore. Select name). Name) | sort name} | FT - AutoSize
any kind of help would be greatly appreciated.
Kind regards
AWT
If you have guests who have connections to 2 or more data stores?
Try this
Get-Datacenter | Get-VM | %{ $vm = $_ Get-Datastore -VM $vm | %{ $vm.Name + "-" + $_.Name } } | ft -AutoSize
____________
Blog: LucD notes
Twitter: lucd22
-
System Center Orchestrator 2012 R2 + Powershell module
Hello
I'm new here and just start using System Center Orchestrator 2012 R2.
I created a file to play a Powershell Script that imports a module.
The PS module has been deployed to all servers in folders.
Executing files, it can't... I founf out that the new PS module is not imported through the host of orchestrator runs the script.
to debug, I have performed in a test files:
Get-module-list | out-file c:\temp\modules.txt
and the new PS module is not listed in the file put out!
I need to reboot servers in folders (or services) to get the new module PS imported successfully?
Thanks a lot guys.
This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)*
Maybe you are looking for
-
Pavilion DV4000: Forgotten Bios password. Disabled system 6961
I forgot the bios password of my laptop after 3 attempts the error msg is 'disabled system [06961} '. I put a lot of codes found on the internet but no solution. Can anyone help?
-
Satellite Pro P300-19 q WLan don't work in Win XP & keyboard problem
I just took delivery of one P300 19 q which seems fine other than... 1. the Wireless does not work 2. the keyboard in my opinion is c * p I removed Vista, I use the laptop for XP and music is much better (not sure if this is related) but I can't get
-
Dell xps m1330 "no battery is detected.
the laptop I use had to be plugged into the wall for many years he used to say plugged and not charging now it says no battery is detected, how can I check to make sure that the problem is with the battery and not with the computer system that I curr
-
Problems of recurrent on my Z3 compact, I checked the IMEI number on the net here:http://103.4.144.182/sonymobile.co.jp/Sony_Mobile.aspx The 'original' number before sending it in, (accepted warranty repair) 'A' out of the box, it came when I bought
-
How to stop an application running in another application.
Hi, good evening. My requriement is that I have an application called 'has' is a 'feature to run automatically at startup. so, when I start my device or an emulator it will start automatically and now I want to stop the application from other applica