Is there any other way to be able to setup a script to be able to run by either double clicking it or some other way other than having to opening powercli and going to the script and running it.
It might not be the best way to do it, but to help out the people not use to running powercli it will help. The script I know is fine to run...we are running win2k8 if that matters
You can create a shortcut and under the properties do a run of PowerShell.exe.
As an argument you pass along the script that PowerShell should run.
In the script you make sure the PowerCLI pssnapin is loaded.
For example, the target of the shortcut could be
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File "MyScript.ps1"
And in MyScript.ps1 you add
Add-PSSnapin VMware.VimAutomation.Core
before the script uses a PowerCLI cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can create a shortcut and under the properties do a run of PowerShell.exe.
As an argument you pass along the script that PowerShell should run.
In the script you make sure the PowerCLI pssnapin is loaded.
For example, the target of the shortcut could be
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File "MyScript.ps1"
And in MyScript.ps1 you add
Add-PSSnapin VMware.VimAutomation.Core
before the script uses a PowerCLI cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It says it needs this
: This cmdlet requires 32bit process. Please run PowerCLI in 32 bit mode.
Hi,
Replace %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File "MyScript.ps1" by %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -File "MyScript.ps1"
Julien
Some PowerCLI cmdlets do indeed need to be run in the PowerShell 32-bit engine.
When on 64-bit system you have 2 PowerShell binaries to run:
32-bit as C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
64-bit as C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Select the appropriate one for your script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
When you use powershell.exe to launch a script, you can use the "-noprofile" switch to use a fresh powershell session.
Afaik you always have a fresh session when you run powershell.exe.
The NoProfile parameter says not to run any of the profile scripts for the session.
See here for the other available parameters.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is what i was saying with the "Fresh Session", but my english is kinda bad i guess 😕
Using this parameter allow you to test script and make it work on standard environnement.
-NoProfile Tells the PowerShell console not to load the current user’s profile.
You can have more information about powershell parameters here : More Powerful Ways to Launch Windows PowerShell
Julien.
Is there a way to place the shortcuts on everyone's desktop that has an account on the server so they can easily run it. As you can see I'm not a windows person..
Thank you for all the great info!!!
Place the shortcuts on "C:\Users\Public\Desktop", it is a hidden folder so you will need to show hidden files and folders.
Julien.