Went to VMWorld and attended PowerCLI session. I am a scripting NOOB and found a script that I want to run. I saved it to:
C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts
But when I go to run the script POWERCLI says it doesn't recognize the name of the script file. I am guessing this is because it isn't looking in the right spot. What am I doing wrong??
You could automate this by placing a 'cd <folder>' in your profile.
See Profile: Autostart Scripts for all the details on profiles.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If your script is called MyScript.ps1 and stored in C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts you can run the script with:
cd "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts" .\MyScript.ps1
Or you can do:
&"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\MyScript.ps1"
Regards, Robert
If you downloaded the script from a website it could be that the execution policy in PowerShell is not set correctly.
You can change the execution policy with
Set-ExecutionPolicy RemoteSigned
or even
Set-ExecutionPolicy Unrestricted
which is of course a certain security risk.
Perhaps you could include the complete error message you're getting ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
So you are saying I have to type the path everytime i want to run a script? There isn't a way to say this is where all of my scripts live?
I did run those commands during install. That is not the issue here.
You could automate this by placing a 'cd <folder>' in your profile.
See Profile: Autostart Scripts for all the details on profiles.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference